Resurrect State directory

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2017-08-03 09:12:58 -07:00
parent 0fa76584f8
commit 642620cae3
No known key found for this signature in database
GPG Key ID: 40CF16616B361216
10 changed files with 47 additions and 13 deletions

View File

@ -6,7 +6,8 @@ import (
func defaultConfig() *server.Config {
return &server.Config{
Root: "/var/lib/containerd",
Root: server.DefaultRootDir,
State: server.DefaultStateDir,
GRPC: server.GRPCConfig{
Address: server.DefaultAddress,
},

View File

@ -6,7 +6,8 @@ import "github.com/containerd/containerd/server"
func defaultConfig() *server.Config {
return &server.Config{
Root: "/var/lib/containerd",
Root: server.DefaultRootDir,
State: server.DefaultStateDir,
GRPC: server.GRPCConfig{
Address: server.DefaultAddress,
},

View File

@ -1,15 +1,11 @@
package main
import (
"os"
"path/filepath"
"github.com/containerd/containerd/server"
)
import "github.com/containerd/containerd/server"
func defaultConfig() *server.Config {
return &server.Config{
Root: filepath.Join(os.Getenv("programfiles"), "containerd", "root"),
Root: server.DefaultRootDir,
State: server.DefaultStateDir,
GRPC: server.GRPCConfig{
Address: server.DefaultAddress,
},

View File

@ -69,7 +69,7 @@ type Config struct {
}
func New(ic *plugin.InitContext) (interface{}, error) {
if err := os.MkdirAll(ic.Root, 0711); err != nil {
if err := os.MkdirAll(ic.State, 0711); err != nil {
return nil, err
}
monitor, err := ic.Get(plugin.TaskMonitorPlugin)
@ -82,7 +82,7 @@ func New(ic *plugin.InitContext) (interface{}, error) {
}
cfg := ic.Config.(*Config)
r := &Runtime{
root: ic.Root,
root: ic.State,
remote: !cfg.NoShim,
shim: cfg.Shim,
shimDebug: cfg.ShimDebug,

View File

@ -9,16 +9,18 @@ import (
"github.com/containerd/containerd/log"
)
func NewContext(ctx context.Context, plugins map[PluginType]map[string]interface{}, root, id string) *InitContext {
func NewContext(ctx context.Context, plugins map[PluginType]map[string]interface{}, root, state, id string) *InitContext {
return &InitContext{
plugins: plugins,
Root: filepath.Join(root, id),
State: filepath.Join(state, id),
Context: log.WithModule(ctx, id),
}
}
type InitContext struct {
Root string
State string
Address string
Context context.Context
Config interface{}

View File

@ -11,6 +11,8 @@ import (
type Config struct {
// Root is the path to a directory where containerd will store persistent data
Root string `toml:"root"`
// State is the path to a directory where containerd will store transient data
State string `toml:"state"`
// GRPC configuration settings
GRPC GRPCConfig `toml:"grpc"`
// Debug and profiling settings

View File

@ -36,9 +36,15 @@ func New(ctx context.Context, config *Config) (*Server, error) {
if config.Root == "" {
return nil, errors.New("root must be specified")
}
if config.State == "" {
return nil, errors.New("state must be specified")
}
if err := os.MkdirAll(config.Root, 0711); err != nil {
return nil, err
}
if err := os.MkdirAll(config.State, 0711); err != nil {
return nil, err
}
if err := apply(ctx, config); err != nil {
return nil, err
}
@ -66,6 +72,7 @@ func New(ctx context.Context, config *Config) (*Server, error) {
ctx,
initialized,
config.Root,
config.State,
id,
)
initContext.Events = s.events

View File

@ -9,6 +9,12 @@ import (
)
const (
// DefaultRootDir is the default location used by containerd to store
// persistent data
DefaultRootDir = "/var/lib/containerd"
// DefaultStateDir is the default location used by containerd to store
// transient data
DefaultStateDir = "/run/containerd"
// DefaultAddress is the default unix socket address
DefaultAddress = "/run/containerd/containerd.sock"
// DefaultDebuggAddress is the default unix socket address for pprof data

View File

@ -5,6 +5,12 @@ package server
import "context"
const (
// DefaultRootDir is the default location used by containerd to store
// persistent data
DefaultRootDir = "/var/lib/containerd"
// DefaultStateDir is the default location used by containerd to store
// transient data
DefaultStateDir = "/run/containerd"
// DefaultAddress is the default unix socket address
DefaultAddress = "/run/containerd/containerd.sock"
// DefaultDebuggAddress is the default unix socket address for pprof data

View File

@ -2,7 +2,20 @@
package server
import "context"
import (
"context"
"os"
"path/filepath"
)
var (
// DefaultRootDir is the default location used by containerd to store
// persistent data
DefaultRootDir = filepath.Join(os.Getenv("programfiles"), "containerd", "root")
// DefaultStateDir is the default location used by containerd to store
// transient data
DefaultStateDir = filepath.Join(os.Getenv("programfiles"), "containerd", "state")
)
const (
// DefaultAddress is the default winpipe address