mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00
libpod: do not leak systemd hc startup unit timer
This fixes a regression added in commit 4fd84190b8, because the name was overwritten by the createTimer() timer call the removeTransientFiles() call removed the new timer and not the startup healthcheck. And then when the container was stopped we leaked it as the wrong unit name was in the state. A new test has been added to ensure the logic works and we never leak the system timers. Fixes #22884 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -272,7 +272,9 @@ func (c *Container) handleRestartPolicy(ctx context.Context) (_ bool, retErr err
|
||||
}
|
||||
|
||||
if c.config.HealthCheckConfig != nil {
|
||||
if err := c.removeTransientFiles(ctx, c.config.StartupHealthCheckConfig != nil && !c.state.StartupHCPassed); err != nil {
|
||||
if err := c.removeTransientFiles(ctx,
|
||||
c.config.StartupHealthCheckConfig != nil && !c.state.StartupHCPassed,
|
||||
c.state.HCUnitName); err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
@ -1590,7 +1592,9 @@ func (c *Container) restartWithTimeout(ctx context.Context, timeout uint) (retEr
|
||||
}
|
||||
|
||||
if c.config.HealthCheckConfig != nil {
|
||||
if err := c.removeTransientFiles(context.Background(), c.config.StartupHealthCheckConfig != nil && !c.state.StartupHCPassed); err != nil {
|
||||
if err := c.removeTransientFiles(context.Background(),
|
||||
c.config.StartupHealthCheckConfig != nil && !c.state.StartupHCPassed,
|
||||
c.state.HCUnitName); err != nil {
|
||||
logrus.Error(err.Error())
|
||||
}
|
||||
}
|
||||
@ -2047,7 +2051,9 @@ func (c *Container) cleanup(ctx context.Context) error {
|
||||
|
||||
// Remove healthcheck unit/timer file if it execs
|
||||
if c.config.HealthCheckConfig != nil {
|
||||
if err := c.removeTransientFiles(ctx, c.config.StartupHealthCheckConfig != nil && !c.state.StartupHCPassed); err != nil {
|
||||
if err := c.removeTransientFiles(ctx,
|
||||
c.config.StartupHealthCheckConfig != nil && !c.state.StartupHCPassed,
|
||||
c.state.HCUnitName); err != nil {
|
||||
logrus.Errorf("Removing timer for container %s healthcheck: %v", c.ID(), err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user