diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_config.go | 2 | ||||
-rw-r--r-- | libpod/container_inspect.go | 1 | ||||
-rw-r--r-- | libpod/define/container_inspect.go | 1 | ||||
-rw-r--r-- | libpod/diff.go | 12 | ||||
-rw-r--r-- | libpod/image/image.go | 3 | ||||
-rw-r--r-- | libpod/oci_conmon_linux.go | 2 | ||||
-rw-r--r-- | libpod/options.go | 11 | ||||
-rw-r--r-- | libpod/runtime_ctr.go | 11 | ||||
-rw-r--r-- | libpod/runtime_img.go | 3 |
9 files changed, 31 insertions, 15 deletions
diff --git a/libpod/container_config.go b/libpod/container_config.go index be24b54d6..e6c3be1bd 100644 --- a/libpod/container_config.go +++ b/libpod/container_config.go @@ -364,4 +364,6 @@ type ContainerMiscConfig struct { Timezone string `json:"timezone,omitempty"` // Umask is the umask inside the container. Umask string `json:"umask,omitempty"` + // PidFile is the file that saves the pid of the container process + PidFile string `json:"pid_file,omitempty"` } diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index e0569e2d4..61cc43314 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -128,6 +128,7 @@ func (c *Container) getContainerInspectData(size bool, driverData *define.Driver StaticDir: config.StaticDir, OCIRuntime: config.OCIRuntime, ConmonPidFile: config.ConmonPidFile, + PidFile: config.PidFile, Name: config.Name, RestartCount: int32(runtimeInfo.RestartCount), Driver: driverData.Name, diff --git a/libpod/define/container_inspect.go b/libpod/define/container_inspect.go index 0f355d20a..1a38f5b0a 100644 --- a/libpod/define/container_inspect.go +++ b/libpod/define/container_inspect.go @@ -627,6 +627,7 @@ type InspectContainerData struct { OCIConfigPath string `json:"OCIConfigPath,omitempty"` OCIRuntime string `json:"OCIRuntime,omitempty"` ConmonPidFile string `json:"ConmonPidFile"` + PidFile string `json:"PidFile"` Name string `json:"Name"` RestartCount int32 `json:"RestartCount"` Driver string `json:"Driver"` diff --git a/libpod/diff.go b/libpod/diff.go index 36d60b838..df1acf4bb 100644 --- a/libpod/diff.go +++ b/libpod/diff.go @@ -1,8 +1,6 @@ package libpod import ( - "io" - "github.com/containers/podman/v3/libpod/layers" "github.com/containers/storage/pkg/archive" "github.com/pkg/errors" @@ -46,16 +44,6 @@ func (r *Runtime) GetDiff(from, to string) ([]archive.Change, error) { return rchanges, err } -// ApplyDiffTarStream applies the changes stored in 'diff' to the layer 'to' -func (r *Runtime) ApplyDiffTarStream(to string, diff io.Reader) error { - toLayer, err := r.getLayerID(to) - if err != nil { - return err - } - _, err = r.store.ApplyDiff(toLayer, diff) - return err -} - // GetLayerID gets a full layer id given a full or partial id // If the id matches a container or image, the id of the top layer is returned // If the id matches a layer, the top layer id is returned diff --git a/libpod/image/image.go b/libpod/image/image.go index 12dc22360..3c9fb3a37 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -617,7 +617,8 @@ func (i *Image) TopLayer() string { func (i *Image) Remove(ctx context.Context, force bool) error { parent, err := i.GetParent(ctx) if err != nil { - return err + logrus.Warnf("error determining parent of image: %v, ignoring the error", err) + parent = nil } if _, err := i.imageruntime.store.DeleteImage(i.ID(), true); err != nil { return err diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go index e3da9a237..c1acec977 100644 --- a/libpod/oci_conmon_linux.go +++ b/libpod/oci_conmon_linux.go @@ -1016,7 +1016,7 @@ func (r *ConmonOCIRuntime) createOCIContainer(ctr *Container, restoreOptions *Co } } - args := r.sharedConmonArgs(ctr, ctr.ID(), ctr.bundlePath(), filepath.Join(ctr.state.RunDir, "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/options.go b/libpod/options.go index 333a7c4a5..5cd0f7b88 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -1692,6 +1692,17 @@ func WithSecrets(secretNames []string) CtrCreateOption { } } +// WithPidFile adds pidFile to the container +func WithPidFile(pidFile string) CtrCreateOption { + return func(ctr *Container) error { + if ctr.valid { + return define.ErrCtrFinalized + } + ctr.config.PidFile = pidFile + return nil + } +} + // Pod Creation Options // WithInfraImage sets the infra image for libpod. diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index f9b5c5c51..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) } @@ -366,6 +373,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. diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index 3588467a5..2b101c01f 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -66,7 +66,8 @@ func (r *Runtime) RemoveImage(ctx context.Context, img *image.Image, force bool) hasChildren, err := img.IsParent(ctx) if err != nil { - return nil, err + logrus.Warnf("error determining if an image is a parent: %v, ignoring the error", err) + hasChildren = false } if (len(img.Names()) > 1 && !img.InputIsID()) || hasChildren { |