summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-05-20 15:29:24 -0400
committerMatthew Heon <matthew.heon@pm.me>2020-05-20 16:11:05 -0400
commit6b9e9610d8ef380d32a682d058157db0f08dd873 (patch)
treeffd1f83437eb6d7e111c91b2036dfd34ff6c78d3 /cmd
parent5ec56dc79093e52abd8e72913aa62932bf12ba6a (diff)
downloadpodman-6b9e9610d8ef380d32a682d058157db0f08dd873.tar.gz
podman-6b9e9610d8ef380d32a682d058157db0f08dd873.tar.bz2
podman-6b9e9610d8ef380d32a682d058157db0f08dd873.zip
Enable cleanup processes for detached exec
The cleanup command creation logic is made public as part of this and wired such that we can call it both within SpecGen (to make container exit commands) and from the ABI detached exec handler. Exit commands are presently only used for detached exec, but theoretically could be turned on for all exec sessions if we wanted (I'm declining to do this because of potential overhead). I also forgot to copy the exit command from the exec config into the ExecOptions struct used by the OCI runtime, so it was not being added. There are also two significant bugfixes for exec in here. One is for updating the status of running exec sessions - this was always failing as I had coded it to remove the exit file *before* reading it, instead of after (oops). The second was that removing a running exec session would always fail because I inverted the check to see if it was running. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/containers/cleanup.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/podman/containers/cleanup.go b/cmd/podman/containers/cleanup.go
index 257efb971..619031208 100644
--- a/cmd/podman/containers/cleanup.go
+++ b/cmd/podman/containers/cleanup.go
@@ -8,6 +8,7 @@ import (
"github.com/containers/libpod/cmd/podman/utils"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@@ -68,6 +69,12 @@ func cleanup(cmd *cobra.Command, args []string) error {
responses, err := registry.ContainerEngine().ContainerCleanup(registry.GetContext(), args, cleanupOptions)
if err != nil {
+ // `podman container cleanup` is almost always run in the
+ // background. Our only way of relaying information to the user
+ // is via syslog.
+ // As such, we need to logrus.Errorf our errors to ensure they
+ // are properly printed if --syslog is set.
+ logrus.Errorf("Error running container cleanup: %v", err)
return err
}
for _, r := range responses {
@@ -76,12 +83,15 @@ func cleanup(cmd *cobra.Command, args []string) error {
continue
}
if r.RmErr != nil {
+ logrus.Errorf("Error removing container: %v", r.RmErr)
errs = append(errs, r.RmErr)
}
if r.RmiErr != nil {
+ logrus.Errorf("Error removing image: %v", r.RmiErr)
errs = append(errs, r.RmiErr)
}
if r.CleanErr != nil {
+ logrus.Errorf("Error cleaning up container: %v", r.CleanErr)
errs = append(errs, r.CleanErr)
}
}