mirror of
https://github.com/containers/podman.git
synced 2025-10-19 20:23:08 +08:00
Configure HealthCheck with podman update
New flags in a `podman update` can change the configuration of HealthCheck when the container is started, without having to restart or recreate the container. This can help determine why a given container suddenly started failing HealthCheck without interfering with the services it provides. For example, reconfigure HealthCheck to keep logs longer than the usual last X results, store logs to other destinations, etc. Fixes: https://issues.redhat.com/browse/RHEL-60561 Signed-off-by: Jan Rodák <hony.com@seznam.cz>
This commit is contained in:
@ -354,7 +354,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions
|
||||
if c.NoHealthCheck {
|
||||
return errors.New("cannot specify both --no-healthcheck and --health-cmd")
|
||||
}
|
||||
s.HealthConfig, err = makeHealthCheckFromCli(c.HealthCmd, c.HealthInterval, c.HealthRetries, c.HealthTimeout, c.HealthStartPeriod, false)
|
||||
s.HealthConfig, err = MakeHealthCheckFromCli(c.HealthCmd, c.HealthInterval, c.HealthRetries, c.HealthTimeout, c.HealthStartPeriod, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -383,7 +383,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions
|
||||
// The hardcoded "1s" will be discarded, as the startup
|
||||
// healthcheck does not have a period. So just hardcode
|
||||
// something that parses correctly.
|
||||
tmpHcConfig, err := makeHealthCheckFromCli(c.StartupHCCmd, c.StartupHCInterval, c.StartupHCRetries, c.StartupHCTimeout, "1s", true)
|
||||
tmpHcConfig, err := MakeHealthCheckFromCli(c.StartupHCCmd, c.StartupHCInterval, c.StartupHCRetries, c.StartupHCTimeout, "1s", true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -948,7 +948,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, startPeriod string, isStartup bool) (*manifest.Schema2HealthConfig, error) {
|
||||
func MakeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, startPeriod string, isStartup bool) (*manifest.Schema2HealthConfig, error) {
|
||||
cmdArr := []string{}
|
||||
isArr := true
|
||||
err := json.Unmarshal([]byte(inCmd), &cmdArr) // array unmarshalling
|
||||
@ -1017,7 +1017,6 @@ func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, start
|
||||
return nil, errors.New("healthcheck-start-period must be 0 seconds or greater")
|
||||
}
|
||||
hc.StartPeriod = startPeriodDuration
|
||||
|
||||
return &hc, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user