server: make logDir configurable

While logDir isn't currently used (until the conmon implementation
lands) it's probably not a great idea to hardcode our defaults. The main
issue with this setting is that the kubelet can override it at will.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
Aleksa Sarai 2016-10-21 20:58:54 +11:00 committed by Aleksa Sarai
parent 33f47d6a6b
commit 96c0966ce9
No known key found for this signature in database
GPG key ID: 9E18AA267DDB8DB4
3 changed files with 10 additions and 2 deletions

View file

@ -78,6 +78,7 @@ func DefaultConfig() *server.Config {
Root: ocidRoot, Root: ocidRoot,
SandboxDir: filepath.Join(ocidRoot, "sandboxes"), SandboxDir: filepath.Join(ocidRoot, "sandboxes"),
ContainerDir: filepath.Join(ocidRoot, "containers"), ContainerDir: filepath.Join(ocidRoot, "containers"),
LogDir: "/var/log/ocid/pods",
}, },
APIConfig: server.APIConfig{ APIConfig: server.APIConfig{
Listen: "/var/run/ocid.sock", Listen: "/var/run/ocid.sock",

View file

@ -33,6 +33,12 @@ type RootConfig struct {
// ContainerDir is the directory where ocid will store all of its container // ContainerDir is the directory where ocid will store all of its container
// state and other information. // state and other information.
ContainerDir string `toml:"container_dir"` 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. // APIConfig represents the "ocid.api" TOML config table.

View file

@ -31,7 +31,6 @@ type sandbox struct {
} }
const ( const (
podInfraRootfs = "/var/lib/ocid/graph/vfs/pause"
podDefaultNamespace = "default" podDefaultNamespace = "default"
) )
@ -141,6 +140,8 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
// creates a spec Generator with the default spec. // creates a spec Generator with the default spec.
g := generate.New() 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") podInfraRootfs := filepath.Join(s.config.Root, "graph/vfs/pause")
// setup defaults for the pod sandbox // setup defaults for the pod sandbox
g.SetRootPath(filepath.Join(podInfraRootfs, "rootfs")) g.SetRootPath(filepath.Join(podInfraRootfs, "rootfs"))
@ -156,7 +157,7 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
// set log directory // set log directory
logDir := req.GetConfig().GetLogDirectory() logDir := req.GetConfig().GetLogDirectory()
if logDir == "" { if logDir == "" {
logDir = fmt.Sprintf("/var/log/ocid/pods/%s", id) logDir = filepath.Join(s.config.LogDir, id)
} }
// set DNS options // set DNS options