From c21faab5302df663a847b727d147c994a94ae3e5 Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Tue, 14 Mar 2017 20:59:00 -0700 Subject: [PATCH] Ensure state dir is created before starting server Signed-off-by: Kenfe-Mickael Laventure --- containerd/main.go | 6 +++++- supervisor/supervisor.go | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/containerd/main.go b/containerd/main.go index 68bdd8eecc4b..c9f5bd37866a 100644 --- a/containerd/main.go +++ b/containerd/main.go @@ -157,6 +157,10 @@ func main() { } func daemon(context *cli.Context) error { + stateDir := context.String("state-dir") + if err := os.MkdirAll(stateDir, 0755); err != nil { + return err + } s := make(chan os.Signal, 2048) signal.Notify(s, syscall.SIGTERM, syscall.SIGINT) // Split the listen string of the form proto://addr @@ -171,7 +175,7 @@ func daemon(context *cli.Context) error { return err } sv, err := supervisor.New( - context.String("state-dir"), + stateDir, context.String("runtime"), context.String("shim"), context.StringSlice("runtime-args"), diff --git a/supervisor/supervisor.go b/supervisor/supervisor.go index e1fd5d647fa5..a6700b1e0789 100644 --- a/supervisor/supervisor.go +++ b/supervisor/supervisor.go @@ -20,9 +20,6 @@ const ( // New returns an initialized Process supervisor. func New(stateDir string, runtimeName, shimName string, runtimeArgs []string, timeout time.Duration, retainCount int) (*Supervisor, error) { startTasks := make(chan *startTask, 10) - if err := os.MkdirAll(stateDir, 0755); err != nil { - return nil, err - } machine, err := CollectMachineInformation() if err != nil { return nil, err