summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2022-08-31 10:58:06 -0400
committerMatthew Heon <matthew.heon@pm.me>2022-08-31 10:58:06 -0400
commitfed4ce0ea9a9c85b45f5f6733f82051ea3a179db (patch)
tree3f82d5728025a77765879df73e23f23b31dd68de /libpod/container_internal.go
parentf98215c668746e9a7b9603448428cd1301a56eac (diff)
downloadpodman-fed4ce0ea9a9c85b45f5f6733f82051ea3a179db.tar.gz
podman-fed4ce0ea9a9c85b45f5f6733f82051ea3a179db.tar.bz2
podman-fed4ce0ea9a9c85b45f5f6733f82051ea3a179db.zip
Inhibit SIGTERM during Conmon startup
If we get a SIGTERM immediately after Conmon starts but before we record its PID in the database, we end up leaking a Conmon and associated OCI runtime process. Inhibit shutdown using the logic we originally wrote to prevent similar issues during container creation to prevent this problem. [NO NEW TESTS NEEDED] No real way to test this I can think of. Fixes #15557 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 60fb29607..7d390ec21 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -27,6 +27,7 @@ import (
cutil "github.com/containers/common/pkg/util"
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/libpod/events"
+ "github.com/containers/podman/v4/libpod/shutdown"
"github.com/containers/podman/v4/pkg/ctime"
"github.com/containers/podman/v4/pkg/lookup"
"github.com/containers/podman/v4/pkg/rootless"
@@ -1038,6 +1039,13 @@ func (c *Container) init(ctx context.Context, retainRetries bool) error {
}
}
+ // To ensure that we don't lose track of Conmon if hit by a SIGTERM
+ // in the middle of setting up the container, inhibit shutdown signals
+ // until after we save Conmon's PID to the state.
+ // TODO: This can likely be removed once conmon-rs support merges.
+ shutdown.Inhibit()
+ defer shutdown.Uninhibit()
+
// With the spec complete, do an OCI create
if _, err = c.ociRuntime.CreateContainer(c, nil); err != nil {
return err
@@ -1073,6 +1081,7 @@ func (c *Container) init(ctx context.Context, retainRetries bool) error {
if err := c.save(); err != nil {
return err
}
+
if c.config.HealthCheckConfig != nil {
if err := c.createTimer(); err != nil {
logrus.Error(err)