mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
report healthcheck start errors
When starting a container consider healthcheck errors fatal. That way user know when systemd-run failed to setup the timer to run the healthcheck and we don't get into a state where the container is running but not the healthcheck. This also fixes the broken error reporting from the systemd-run exec, if the binary could not be run the output was just empty leaving the users with no idea what failed. Fixes #25034 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -1144,7 +1144,7 @@ func (c *Container) init(ctx context.Context, retainRetries bool) error {
|
||||
timer = c.config.StartupHealthCheckConfig.Interval.String()
|
||||
}
|
||||
if err := c.createTimer(timer, c.config.StartupHealthCheckConfig != nil); err != nil {
|
||||
logrus.Error(err)
|
||||
return fmt.Errorf("create healthcheck: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1333,10 +1333,10 @@ func (c *Container) start() error {
|
||||
// to update status in such case.
|
||||
if c.config.HealthCheckConfig != nil && !(len(c.config.HealthCheckConfig.Test) == 1 && c.config.HealthCheckConfig.Test[0] == "NONE") {
|
||||
if err := c.updateHealthStatus(define.HealthCheckStarting); err != nil {
|
||||
logrus.Error(err)
|
||||
return fmt.Errorf("update healthcheck status: %w", err)
|
||||
}
|
||||
if err := c.startTimer(c.config.StartupHealthCheckConfig != nil); err != nil {
|
||||
logrus.Error(err)
|
||||
return fmt.Errorf("start healthcheck: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1627,7 +1627,7 @@ func (c *Container) unpause() error {
|
||||
timer = c.config.StartupHealthCheckConfig.Interval.String()
|
||||
}
|
||||
if err := c.createTimer(timer, isStartupHealthCheck); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("create healthcheck: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -2895,7 +2895,9 @@ func (c *Container) resetHealthCheckTimers(noHealthCheck bool, changedTimer bool
|
||||
|
||||
if !isStartup {
|
||||
if c.state.StartupHCPassed || c.config.StartupHealthCheckConfig == nil {
|
||||
c.recreateHealthCheckTimer(context.Background(), false, false)
|
||||
if err := c.recreateHealthCheckTimer(context.Background(), false, false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -2908,7 +2910,9 @@ func (c *Container) resetHealthCheckTimers(noHealthCheck bool, changedTimer bool
|
||||
return err
|
||||
}
|
||||
if wasEnabledHealthCheck {
|
||||
c.recreateHealthCheckTimer(context.Background(), true, true)
|
||||
if err := c.recreateHealthCheckTimer(context.Background(), true, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user