mirror of
https://github.com/containers/podman.git
synced 2025-08-03 01:37:51 +08:00
container restart: clean up healthcheck state
When restarting a container, clean up the healthcheck state by removing the old log on disk. Carrying over the old state can lead to various issues, for instance, in a wrong failing streak and hence wrong behaviour after the restart. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2144754 Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
@ -1077,6 +1077,15 @@ func (c *Container) init(ctx context.Context, retainRetries bool) error {
|
||||
c.state.RestartCount = 0
|
||||
}
|
||||
|
||||
// bugzilla.redhat.com/show_bug.cgi?id=2144754:
|
||||
// In case of a restart, make sure to remove the healthcheck log to
|
||||
// have a clean state.
|
||||
if path := c.healthCheckLogPath(); path != "" {
|
||||
if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.save(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user