From 8d77404a753e070f60630553de24f61503f4d35b Mon Sep 17 00:00:00 2001 From: dpacgdm Date: Thu, 9 Jul 2026 14:29:29 +0530 Subject: [PATCH] config: include --cri-timeout in containerd health-checker defaults The health-checker binary honors --cri-timeout when passed via custom plugin rule args. The default containerd configs omitted the flag, so crictl used the 2s built-in default. Document the flag in the sample configs and add a unit test that --cri-timeout parses correctly. Signed-off-by: dpacgdm --- cmd/healthchecker/options/options_test.go | 19 +++++++++++++++++++ config/health-checker-containerd.json | 3 ++- config/windows-health-checker-containerd.json | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cmd/healthchecker/options/options_test.go b/cmd/healthchecker/options/options_test.go index 94bf75083..eb664c5c1 100644 --- a/cmd/healthchecker/options/options_test.go +++ b/cmd/healthchecker/options/options_test.go @@ -18,7 +18,9 @@ package options import ( "testing" + "time" + "github.com/spf13/pflag" "github.com/stretchr/testify/assert" "k8s.io/node-problem-detector/pkg/healthchecker/types" @@ -74,3 +76,20 @@ func TestIsValid(t *testing.T) { }) } } + +func TestCriTimeoutFlagParsing(t *testing.T) { + hco := NewHealthCheckerOptions() + fs := pflag.NewFlagSet("test", pflag.ContinueOnError) + assert.NoError(t, hco.AddFlags(fs)) + + assert.NoError(t, fs.Parse([]string{ + "--component=cri", + "--enable-repair=false", + "--cri-timeout=10s", + "--health-check-timeout=60s", + })) + + assert.Equal(t, 10*time.Second, hco.CriTimeout) + assert.Equal(t, 60*time.Second, hco.HealthCheckTimeout) + assert.Equal(t, types.CRIComponent, hco.Component) +} diff --git a/config/health-checker-containerd.json b/config/health-checker-containerd.json index a6fe0b95e..801fc2248 100644 --- a/config/health-checker-containerd.json +++ b/config/health-checker-containerd.json @@ -1,4 +1,4 @@ -{ +{ "plugin": "custom", "pluginConfig": { "invoke_interval": "10s", @@ -25,6 +25,7 @@ "--component=cri", "--enable-repair=true", "--cooldown-time=2m", + "--cri-timeout=10s", "--health-check-timeout=60s" ], "timeout": "3m" diff --git a/config/windows-health-checker-containerd.json b/config/windows-health-checker-containerd.json index 329e1a66e..7f82ab1e9 100644 --- a/config/windows-health-checker-containerd.json +++ b/config/windows-health-checker-containerd.json @@ -25,10 +25,10 @@ "--component=cri", "--enable-repair=true", "--cooldown-time=2m", + "--cri-timeout=10s", "--health-check-timeout=60s" ], "timeout": "3m" } ] } - \ No newline at end of file