Resurrect State directory
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
0fa76584f8
commit
642620cae3
@ -6,7 +6,8 @@ import (
|
|||||||
|
|
||||||
func defaultConfig() *server.Config {
|
func defaultConfig() *server.Config {
|
||||||
return &server.Config{
|
return &server.Config{
|
||||||
Root: "/var/lib/containerd",
|
Root: server.DefaultRootDir,
|
||||||
|
State: server.DefaultStateDir,
|
||||||
GRPC: server.GRPCConfig{
|
GRPC: server.GRPCConfig{
|
||||||
Address: server.DefaultAddress,
|
Address: server.DefaultAddress,
|
||||||
},
|
},
|
||||||
|
@ -6,7 +6,8 @@ import "github.com/containerd/containerd/server"
|
|||||||
|
|
||||||
func defaultConfig() *server.Config {
|
func defaultConfig() *server.Config {
|
||||||
return &server.Config{
|
return &server.Config{
|
||||||
Root: "/var/lib/containerd",
|
Root: server.DefaultRootDir,
|
||||||
|
State: server.DefaultStateDir,
|
||||||
GRPC: server.GRPCConfig{
|
GRPC: server.GRPCConfig{
|
||||||
Address: server.DefaultAddress,
|
Address: server.DefaultAddress,
|
||||||
},
|
},
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import "github.com/containerd/containerd/server"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"github.com/containerd/containerd/server"
|
|
||||||
)
|
|
||||||
|
|
||||||
func defaultConfig() *server.Config {
|
func defaultConfig() *server.Config {
|
||||||
return &server.Config{
|
return &server.Config{
|
||||||
Root: filepath.Join(os.Getenv("programfiles"), "containerd", "root"),
|
Root: server.DefaultRootDir,
|
||||||
|
State: server.DefaultStateDir,
|
||||||
GRPC: server.GRPCConfig{
|
GRPC: server.GRPCConfig{
|
||||||
Address: server.DefaultAddress,
|
Address: server.DefaultAddress,
|
||||||
},
|
},
|
||||||
|
@ -69,7 +69,7 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func New(ic *plugin.InitContext) (interface{}, error) {
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
monitor, err := ic.Get(plugin.TaskMonitorPlugin)
|
monitor, err := ic.Get(plugin.TaskMonitorPlugin)
|
||||||
@ -82,7 +82,7 @@ func New(ic *plugin.InitContext) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
cfg := ic.Config.(*Config)
|
cfg := ic.Config.(*Config)
|
||||||
r := &Runtime{
|
r := &Runtime{
|
||||||
root: ic.Root,
|
root: ic.State,
|
||||||
remote: !cfg.NoShim,
|
remote: !cfg.NoShim,
|
||||||
shim: cfg.Shim,
|
shim: cfg.Shim,
|
||||||
shimDebug: cfg.ShimDebug,
|
shimDebug: cfg.ShimDebug,
|
||||||
|
@ -9,16 +9,18 @@ import (
|
|||||||
"github.com/containerd/containerd/log"
|
"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{
|
return &InitContext{
|
||||||
plugins: plugins,
|
plugins: plugins,
|
||||||
Root: filepath.Join(root, id),
|
Root: filepath.Join(root, id),
|
||||||
|
State: filepath.Join(state, id),
|
||||||
Context: log.WithModule(ctx, id),
|
Context: log.WithModule(ctx, id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type InitContext struct {
|
type InitContext struct {
|
||||||
Root string
|
Root string
|
||||||
|
State string
|
||||||
Address string
|
Address string
|
||||||
Context context.Context
|
Context context.Context
|
||||||
Config interface{}
|
Config interface{}
|
||||||
|
@ -11,6 +11,8 @@ import (
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
// Root is the path to a directory where containerd will store persistent data
|
// Root is the path to a directory where containerd will store persistent data
|
||||||
Root string `toml:"root"`
|
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 configuration settings
|
||||||
GRPC GRPCConfig `toml:"grpc"`
|
GRPC GRPCConfig `toml:"grpc"`
|
||||||
// Debug and profiling settings
|
// Debug and profiling settings
|
||||||
|
@ -36,9 +36,15 @@ func New(ctx context.Context, config *Config) (*Server, error) {
|
|||||||
if config.Root == "" {
|
if config.Root == "" {
|
||||||
return nil, errors.New("root must be specified")
|
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 {
|
if err := os.MkdirAll(config.Root, 0711); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if err := os.MkdirAll(config.State, 0711); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if err := apply(ctx, config); err != nil {
|
if err := apply(ctx, config); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -66,6 +72,7 @@ func New(ctx context.Context, config *Config) (*Server, error) {
|
|||||||
ctx,
|
ctx,
|
||||||
initialized,
|
initialized,
|
||||||
config.Root,
|
config.Root,
|
||||||
|
config.State,
|
||||||
id,
|
id,
|
||||||
)
|
)
|
||||||
initContext.Events = s.events
|
initContext.Events = s.events
|
||||||
|
@ -9,6 +9,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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 is the default unix socket address
|
||||||
DefaultAddress = "/run/containerd/containerd.sock"
|
DefaultAddress = "/run/containerd/containerd.sock"
|
||||||
// DefaultDebuggAddress is the default unix socket address for pprof data
|
// DefaultDebuggAddress is the default unix socket address for pprof data
|
||||||
|
@ -5,6 +5,12 @@ package server
|
|||||||
import "context"
|
import "context"
|
||||||
|
|
||||||
const (
|
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 is the default unix socket address
|
||||||
DefaultAddress = "/run/containerd/containerd.sock"
|
DefaultAddress = "/run/containerd/containerd.sock"
|
||||||
// DefaultDebuggAddress is the default unix socket address for pprof data
|
// DefaultDebuggAddress is the default unix socket address for pprof data
|
||||||
|
@ -2,7 +2,20 @@
|
|||||||
|
|
||||||
package server
|
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 (
|
const (
|
||||||
// DefaultAddress is the default winpipe address
|
// DefaultAddress is the default winpipe address
|
||||||
|
Loading…
Reference in New Issue
Block a user