diff --git a/cmd/server/config.go b/cmd/server/config.go index 240a6a8a..97de9786 100644 --- a/cmd/server/config.go +++ b/cmd/server/config.go @@ -68,6 +68,9 @@ selinux = {{ .SELinux }} pause = "{{ .Pause }}" `)) +// TODO: Currently ImageDir isn't really used, so we haven't added it to this +// template. Add it once the storage code has been merged. + // DefaultConfig returns the default configuration for ocid. func DefaultConfig() *server.Config { return &server.Config{ @@ -75,6 +78,7 @@ func DefaultConfig() *server.Config { Root: ocidRoot, SandboxDir: filepath.Join(ocidRoot, "sandboxes"), ContainerDir: filepath.Join(ocidRoot, "containers"), + LogDir: "/var/log/ocid/pods", }, APIConfig: server.APIConfig{ Listen: "/var/run/ocid.sock", @@ -88,8 +92,8 @@ func DefaultConfig() *server.Config { SELinux: selinux.SelinuxEnabled(), }, ImageConfig: server.ImageConfig{ - Pause: pausePath, - ImageStore: filepath.Join(ocidRoot, "store"), + Pause: pausePath, + ImageDir: filepath.Join(ocidRoot, "store"), }, } } diff --git a/server/config.go b/server/config.go index 660d45b4..afdf9551 100644 --- a/server/config.go +++ b/server/config.go @@ -33,6 +33,12 @@ type RootConfig struct { // ContainerDir is the directory where ocid will store all of its container // state and other information. ContainerDir string `toml:"container_dir"` + + // LogDir is the default log directory were all logs will go unless kubelet + // tells us to put them somewhere else. + // + // TODO: This is currently unused until the conmon logging rewrite is done. + LogDir string `toml:"log_dir"` } // APIConfig represents the "ocid.api" TOML config table. @@ -70,7 +76,9 @@ type ImageConfig struct { Pause string `toml:"pause"` // ImageStore is the directory where the ocid image store will be stored. - ImageStore string + // TODO: This is currently not really used because we don't have + // containers/storage integrated. + ImageDir string `toml:"image_dir"` } // tomlConfig is another way of looking at a Config, which is diff --git a/server/image.go b/server/image.go index 82405daa..248c8fad 100644 --- a/server/image.go +++ b/server/image.go @@ -59,10 +59,10 @@ func (s *Server) PullImage(ctx context.Context, req *pb.PullImageRequest) (*pb.P return nil, err } - if err = os.Mkdir(filepath.Join(s.config.ImageStore, tr.StringWithinTransport()), 0755); err != nil { + if err = os.Mkdir(filepath.Join(s.config.ImageDir, tr.StringWithinTransport()), 0755); err != nil { return nil, err } - dir, err := directory.NewReference(filepath.Join(s.config.ImageStore, tr.StringWithinTransport())) + dir, err := directory.NewReference(filepath.Join(s.config.ImageDir, tr.StringWithinTransport())) if err != nil { return nil, err } diff --git a/server/sandbox.go b/server/sandbox.go index 8de16670..a84de4f2 100644 --- a/server/sandbox.go +++ b/server/sandbox.go @@ -31,7 +31,6 @@ type sandbox struct { } const ( - podInfraRootfs = "/var/lib/ocid/graph/vfs/pause" podDefaultNamespace = "default" ) @@ -141,6 +140,8 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest // creates a spec Generator with the default spec. g := generate.New() + // TODO: Make the `graph/vfs` part of this configurable once the storage + // integration has been merged. podInfraRootfs := filepath.Join(s.config.Root, "graph/vfs/pause") // setup defaults for the pod sandbox g.SetRootPath(filepath.Join(podInfraRootfs, "rootfs")) @@ -156,7 +157,7 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest // set log directory logDir := req.GetConfig().GetLogDirectory() if logDir == "" { - logDir = fmt.Sprintf("/var/log/ocid/pods/%s", id) + logDir = filepath.Join(s.config.LogDir, id) } // set DNS options diff --git a/server/server.go b/server/server.go index b16755b6..5d4181b3 100644 --- a/server/server.go +++ b/server/server.go @@ -233,7 +233,7 @@ func New(config *Config) (*Server, error) { utils.StartReaper() - if err := os.MkdirAll(config.ImageStore, 0755); err != nil { + if err := os.MkdirAll(config.ImageDir, 0755); err != nil { return nil, err }