From 728b73d7c4186f4f0f9431d84ec2c5883f38ff20 Mon Sep 17 00:00:00 2001
From: chenkang <kongchen28@gmail.com>
Date: Sat, 17 Apr 2021 21:15:08 +0800
Subject: set pidfile default value int containerconfig

Signed-off-by: chenkang <kongchen28@gmail.com>
---
 libpod/oci_conmon_linux.go | 7 +------
 libpod/runtime_ctr.go      | 4 ++++
 2 files changed, 5 insertions(+), 6 deletions(-)

(limited to 'libpod')

diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go
index c5735d114..dbe91c232 100644
--- a/libpod/oci_conmon_linux.go
+++ b/libpod/oci_conmon_linux.go
@@ -1025,12 +1025,7 @@ func (r *ConmonOCIRuntime) createOCIContainer(ctr *Container, restoreOptions *Co
 		}
 	}
 
-	pidfile := ctr.config.PidFile
-	if pidfile == "" {
-		pidfile = filepath.Join(ctr.state.RunDir, "pidfile")
-	}
-
-	args := r.sharedConmonArgs(ctr, ctr.ID(), ctr.bundlePath(), pidfile, ctr.LogPath(), r.exitsDir, ociLog, ctr.LogDriver(), logTag)
+	args := r.sharedConmonArgs(ctr, ctr.ID(), ctr.bundlePath(), ctr.config.PidFile, ctr.LogPath(), r.exitsDir, ociLog, ctr.LogDriver(), logTag)
 
 	if ctr.config.Spec.Process.Terminal {
 		args = append(args, "-t")
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