Skip to content

Commit

Permalink
allow setting crictl timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhungus committed Sep 15, 2022
1 parent ef7df6c commit ac90360
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmd/healthchecker/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type HealthCheckerOptions struct {
EnableRepair bool
CriCtlPath string
CriSocketPath string
CriTimeout time.Duration
CoolDownTime time.Duration
LoopBackTime time.Duration
HealthCheckTimeout time.Duration
Expand All @@ -62,6 +63,8 @@ func (hco *HealthCheckerOptions) AddFlags(fs *pflag.FlagSet) {
"The path to the crictl binary. This is used to check health of cri component.")
fs.StringVar(&hco.CriSocketPath, "cri-socket-path", types.DefaultCriSocketPath,
"The path to the cri socket. Used with crictl to specify the socket path.")
fs.DurationVar(&hco.CriTimeout, "cri-timeout", types.DefaultCriTimeout,
"The duration to wait for crictl to run.")
fs.DurationVar(&hco.CoolDownTime, "cooldown-time", types.DefaultCoolDownTime,
"The duration to wait for the service to be up before attempting repair.")
fs.DurationVar(&hco.LoopBackTime, "loopback-time", types.DefaultLoopBackTime,
Expand Down
2 changes: 1 addition & 1 deletion pkg/healthchecker/health_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func getHealthCheckFunc(hco *options.HealthCheckerOptions) func() (bool, error)
}
case types.CRIComponent:
return func() (bool, error) {
if _, err := execCommand(hco.HealthCheckTimeout, hco.CriCtlPath, "--runtime-endpoint="+hco.CriSocketPath, "pods", "--latest"); err != nil {
if _, err := execCommand(hco.HealthCheckTimeout, hco.CriCtlPath, "--timeout="+hco.CriTimeout.String()+"--runtime-endpoint="+hco.CriSocketPath, "pods", "--latest"); err != nil {
return false, nil
}
return true, nil
Expand Down
1 change: 1 addition & 0 deletions pkg/healthchecker/types/types_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ package types
const (
DefaultCriCtl = "/usr/bin/crictl"
DefaultCriSocketPath = "unix:///var/run/containerd/containerd.sock"
DefaultCriTimeout = "2s"
UptimeTimeLayout = "Mon 2006-01-02 15:04:05 MST"
)
1 change: 1 addition & 0 deletions pkg/healthchecker/types/types_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package types
const (
DefaultCriCtl = "C:/etc/kubernetes/node/bin/crictl.exe"
DefaultCriSocketPath = "npipe:////./pipe/containerd-containerd"
DefaultCriTimeout = "2s"
UptimeTimeLayout = "Mon 02 Jan 2006 15:04:05 MST"
LogParsingTimeFormat = "yyyy-MM-dd HH:mm:ss"
)

0 comments on commit ac90360

Please sign in to comment.