Merge pull request #169 from cyphar/make-configurable
server: make more things configurable
This commit is contained in:
commit
02ec8754f5
5 changed files with 21 additions and 8 deletions
|
@ -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"),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue