Skip to content

Commit b6d8069

Browse files
committed
allow setting crictl timeout
1 parent 6de3fab commit b6d8069

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

cmd/healthchecker/options/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type HealthCheckerOptions struct {
3939
EnableRepair bool
4040
CriCtlPath string
4141
CriSocketPath string
42+
CriTimeout time.Duration
4243
CoolDownTime time.Duration
4344
LoopBackTime time.Duration
4445
HealthCheckTimeout time.Duration
@@ -62,6 +63,8 @@ func (hco *HealthCheckerOptions) AddFlags(fs *pflag.FlagSet) {
6263
"The path to the crictl binary. This is used to check health of cri component.")
6364
fs.StringVar(&hco.CriSocketPath, "cri-socket-path", types.DefaultCriSocketPath,
6465
"The path to the cri socket. Used with crictl to specify the socket path.")
66+
fs.DurationVar(&hco.CriTimeout, "cri-timeout", types.DefaultCriTimeout,
67+
"The duration to wait for crictl to run.")
6568
fs.DurationVar(&hco.CoolDownTime, "cooldown-time", types.DefaultCoolDownTime,
6669
"The duration to wait for the service to be up before attempting repair.")
6770
fs.DurationVar(&hco.LoopBackTime, "loopback-time", types.DefaultLoopBackTime,

pkg/healthchecker/health_checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func getHealthCheckFunc(hco *options.HealthCheckerOptions) func() (bool, error)
150150
}
151151
case types.CRIComponent:
152152
return func() (bool, error) {
153-
if _, err := execCommand(hco.HealthCheckTimeout, hco.CriCtlPath, "--runtime-endpoint="+hco.CriSocketPath, "pods", "--latest"); err != nil {
153+
if _, err := execCommand(hco.HealthCheckTimeout, hco.CriCtlPath, "--timeout="+hco.CriTimeout.String()+"--runtime-endpoint="+hco.CriSocketPath, "pods", "--latest"); err != nil {
154154
return false, nil
155155
}
156156
return true, nil

pkg/healthchecker/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
const (
2828
DefaultLoopBackTime = 0 * time.Minute
29+
DefaultCriTimeout = 2 * time.Second
2930
DefaultCoolDownTime = 2 * time.Minute
3031
DefaultHealthCheckTimeout = 10 * time.Second
3132
CmdTimeout = 10 * time.Second

0 commit comments

Comments
 (0)