mirror of
https://github.com/containers/podman.git
synced 2025-10-15 18:23:30 +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:
@ -6,8 +6,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
@ -1521,25 +1519,11 @@ func WithHealthCheckLogDestination(destination string) CtrCreateOption {
|
||||
if ctr.valid {
|
||||
return define.ErrCtrFinalized
|
||||
}
|
||||
switch destination {
|
||||
case define.HealthCheckEventsLoggerDestination, define.DefaultHealthCheckLocalDestination:
|
||||
ctr.config.HealthLogDestination = destination
|
||||
default:
|
||||
fileInfo, err := os.Stat(destination)
|
||||
if err != nil {
|
||||
return fmt.Errorf("HealthCheck Log '%s' destination error: %w", destination, err)
|
||||
}
|
||||
mode := fileInfo.Mode()
|
||||
if !mode.IsDir() {
|
||||
return fmt.Errorf("HealthCheck Log '%s' destination must be directory", destination)
|
||||
}
|
||||
|
||||
absPath, err := filepath.Abs(destination)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctr.config.HealthLogDestination = absPath
|
||||
dest, err := define.GetValidHealthCheckDestination(destination)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctr.config.HealthLogDestination = dest
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user