summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-10-07 02:54:13 -0700
committerGitHub <noreply@github.com>2019-10-07 02:54:13 -0700
commit589261f275b485d78a6ac1bd7b95578257fc020f (patch)
tree796be4128050ff418334c4e2a049ecb06cf8f1a2 /libpod
parent2c2782a2179aee6c76d90e864708e2e5ceb09349 (diff)
parentbb803b8f7a475a3128555899d7ae0600dc0a055e (diff)
downloadpodman-589261f275b485d78a6ac1bd7b95578257fc020f.tar.gz
podman-589261f275b485d78a6ac1bd7b95578257fc020f.tar.bz2
podman-589261f275b485d78a6ac1bd7b95578257fc020f.zip
Merge pull request #4196 from mheon/normal_remove_on_evict
When evicting containers, perform a normal remove first
Diffstat (limited to 'libpod')
-rw-r--r--libpod/runtime_ctr.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index 1a2987244..78176a400 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -576,11 +576,33 @@ func (r *Runtime) evictContainer(ctx context.Context, idOrName string, removeVol
if !r.valid {
return "", define.ErrRuntimeStopped
}
+
id, err := r.state.LookupContainerID(idOrName)
if err != nil {
return "", errors.Wrapf(err, "Failed to find container %q in state", idOrName)
}
+ // Begin by trying a normal removal. Valid containers will be removed normally.
+ tmpCtr, err := r.state.Container(id)
+ if err == nil {
+ logrus.Infof("Container %s successfully retrieved from state, attempting normal removal", id)
+ // Assume force = true for the evict case
+ err = r.removeContainer(ctx, tmpCtr, true, removeVolume, false)
+ if !tmpCtr.valid {
+ // If the container is marked invalid, remove succeeded
+ // in kicking it out of the state - no need to continue.
+ return id, err
+ }
+
+ if err == nil {
+ // Something has gone seriously wrong - no error but
+ // container was not removed.
+ logrus.Errorf("Container %s not removed with no error", id)
+ } else {
+ logrus.Warnf("Failed to removal container %s normally, proceeding with evict: %v", id, err)
+ }
+ }
+
// Error out if the container does not exist in libpod
exists, err := r.state.HasContainer(id)
if err != nil {