Skip to content

Commit 406616d

Browse files
Merge pull request #16111 from vrothberg/healthcheck-fixes
healthcheck: fix --on-failure=stop
2 parents bb0b184 + 4dd6727 commit 406616d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

libpod/container_internal.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,12 +1285,6 @@ func (c *Container) stop(timeout uint) error {
12851285
c.lock.Unlock()
12861286
}
12871287

1288-
if c.config.HealthCheckConfig != nil {
1289-
if err := c.removeTransientFiles(context.Background()); err != nil {
1290-
logrus.Error(err.Error())
1291-
}
1292-
}
1293-
12941288
stopErr := c.ociRuntime.StopContainer(c, timeout, all)
12951289

12961290
if !c.batched {
@@ -1415,6 +1409,11 @@ func (c *Container) restartWithTimeout(ctx context.Context, timeout uint) (retEr
14151409
if err := c.stop(timeout); err != nil {
14161410
return err
14171411
}
1412+
if c.config.HealthCheckConfig != nil {
1413+
if err := c.removeTransientFiles(context.Background()); err != nil {
1414+
logrus.Error(err.Error())
1415+
}
1416+
}
14181417
// Old versions of conmon have a bug where they create the exit file before
14191418
// closing open file descriptors causing a race condition when restarting
14201419
// containers with open ports since we cannot bind the ports as they're not

test/system/220-healthcheck.bats

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\"
123123
# kill and stop yield the container into a non-running state
124124
is "$output" ".* $policy" "container was stopped/killed"
125125
assert "$output" != "running $policy"
126+
# also make sure that it's not stuck in the stopping state
127+
assert "$output" != "stopping $policy"
126128
fi
127129

128130
run_podman rm -f -t0 $ctr

0 commit comments

Comments
 (0)