Skip to content

Commit ac90360

Browse files
committed
allow setting crictl timeout
1 parent ef7df6c commit ac90360

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-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_linux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ package types
1919
const (
2020
DefaultCriCtl = "/usr/bin/crictl"
2121
DefaultCriSocketPath = "unix:///var/run/containerd/containerd.sock"
22+
DefaultCriTimeout = "2s"
2223
UptimeTimeLayout = "Mon 2006-01-02 15:04:05 MST"
2324
)

pkg/healthchecker/types/types_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package types
1919
const (
2020
DefaultCriCtl = "C:/etc/kubernetes/node/bin/crictl.exe"
2121
DefaultCriSocketPath = "npipe:////./pipe/containerd-containerd"
22+
DefaultCriTimeout = "2s"
2223
UptimeTimeLayout = "Mon 02 Jan 2006 15:04:05 MST"
2324
LogParsingTimeFormat = "yyyy-MM-dd HH:mm:ss"
2425
)

0 commit comments

Comments
 (0)