Skip to content

Commit

Permalink
Merge pull request #16111 from vrothberg/healthcheck-fixes
Browse files Browse the repository at this point in the history
healthcheck: fix --on-failure=stop
  • Loading branch information
openshift-merge-robot authored Oct 11, 2022
2 parents bb0b184 + 4dd6727 commit 406616d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 5 additions & 6 deletions libpod/container_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1285,12 +1285,6 @@ func (c *Container) stop(timeout uint) error {
c.lock.Unlock()
}

if c.config.HealthCheckConfig != nil {
if err := c.removeTransientFiles(context.Background()); err != nil {
logrus.Error(err.Error())
}
}

stopErr := c.ociRuntime.StopContainer(c, timeout, all)

if !c.batched {
Expand Down Expand Up @@ -1415,6 +1409,11 @@ func (c *Container) restartWithTimeout(ctx context.Context, timeout uint) (retEr
if err := c.stop(timeout); err != nil {
return err
}
if c.config.HealthCheckConfig != nil {
if err := c.removeTransientFiles(context.Background()); err != nil {
logrus.Error(err.Error())
}
}
// Old versions of conmon have a bug where they create the exit file before
// closing open file descriptors causing a race condition when restarting
// containers with open ports since we cannot bind the ports as they're not
Expand Down
2 changes: 2 additions & 0 deletions test/system/220-healthcheck.bats
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\"
# kill and stop yield the container into a non-running state
is "$output" ".* $policy" "container was stopped/killed"
assert "$output" != "running $policy"
# also make sure that it's not stuck in the stopping state
assert "$output" != "stopping $policy"
fi

run_podman rm -f -t0 $ctr
Expand Down

0 comments on commit 406616d

Please sign in to comment.