From 728b73d7c4186f4f0f9431d84ec2c5883f38ff20 Mon Sep 17 00:00:00 2001 From: chenkang Date: Sat, 17 Apr 2021 21:15:08 +0800 Subject: set pidfile default value int containerconfig Signed-off-by: chenkang --- libpod/runtime_ctr.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libpod/runtime_ctr.go') diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index f9b5c5c51..6290479a8 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -366,6 +366,10 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai ctr.config.ConmonPidFile = filepath.Join(ctr.state.RunDir, "conmon.pid") } + if ctr.config.PidFile == "" { + ctr.config.PidFile = filepath.Join(ctr.state.RunDir, "pidfile") + } + // Go through named volumes and add them. // If they don't exist they will be created using basic options. // Maintain an array of them - we need to lock them later. -- cgit v1.2.3-54-g00ecf From a35e16c23456a8fba8d2f627ac64f647aa6f0722 Mon Sep 17 00:00:00 2001 From: chenkang Date: Sun, 18 Apr 2021 00:02:50 +0800 Subject: support pidfile on container restore Signed-off-by: chenkang --- libpod/runtime_ctr.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libpod/runtime_ctr.go') diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index 6290479a8..0acf88cbc 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -69,6 +69,13 @@ func (r *Runtime) RestoreContainer(ctx context.Context, rSpec *spec.Spec, config ctr.config.ConmonPidFile = "" } + // If the path to PidFile starts with the default value (RunRoot), then + // the user has not specified '--pidfile' during run or create (probably). + // In that case reset PidFile to be set to the default value later. + if strings.HasPrefix(ctr.config.PidFile, r.storageConfig.RunRoot) { + ctr.config.PidFile = "" + } + return r.setupContainer(ctx, ctr) } -- cgit v1.2.3-54-g00ecf