From 18516e2833ffca46a9644d7d2dba496175ac51e2 Mon Sep 17 00:00:00 2001 From: "nmstate-ai[bot]" <275024212+nmstate-ai[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 16:27:14 +0200 Subject: [PATCH] Limit liveness probe to loopback interface to avoid short write errors (#1486) The handler liveness probe runs `nmstatectl show` which outputs the full network state (~83KB). Kubernetes exec probes have a 10KB output limit, causing "short write" errors in kubelet logs. Restrict the probe to query only the loopback interface (`nmstatectl show lo`) which produces ~685 bytes of output. The loopback interface is always present on every node, making it a reliable liveness check target. Fixes: https://github.com/nmstate/kubernetes-nmstate/issues/1476 Signed-off-by: nmstate-ai <275024212+nmstate-ai@users.noreply.github.com> Co-authored-by: nmstate-ai <275024212+nmstate-ai@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) (cherry picked from commit 1f02e2588acf7beb08677a4900d29afffb570fde) Signed-off-by: Mat Kowalski --- controllers/operator/nmstate_controller_test.go | 6 +++--- deploy/handler/operator.yaml | 2 +- test/e2e/operator/nmstate_install_test.go | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/controllers/operator/nmstate_controller_test.go b/controllers/operator/nmstate_controller_test.go index ab81f47367..3544752813 100644 --- a/controllers/operator/nmstate_controller_test.go +++ b/controllers/operator/nmstate_controller_test.go @@ -487,7 +487,7 @@ var _ = Describe("NMState controller reconcile", func() { ds := &appsv1.DaemonSet{} err := cl.Get(context.Background(), handlerKey, ds) Expect(err).ToNot(HaveOccurred()) - expectedCommand := "nmstatectl show -vv 2>&1" + expectedCommand := "nmstatectl show lo -vv 2>&1" Expect(ds.Spec.Template.Spec.Containers[0].LivenessProbe.Exec.Command).To(ContainElement(expectedCommand)) }) }) @@ -515,7 +515,7 @@ var _ = Describe("NMState controller reconcile", func() { ds := &appsv1.DaemonSet{} err := cl.Get(context.Background(), handlerKey, ds) Expect(err).ToNot(HaveOccurred()) - expectedCommand := "nmstatectl show 2>&1" + expectedCommand := "nmstatectl show lo 2>&1" Expect(ds.Spec.Template.Spec.Containers[0].LivenessProbe.Exec.Command).To(ContainElement(expectedCommand)) }) }) @@ -542,7 +542,7 @@ var _ = Describe("NMState controller reconcile", func() { ds := &appsv1.DaemonSet{} err := cl.Get(context.Background(), handlerKey, ds) Expect(err).ToNot(HaveOccurred()) - expectedCommand := "nmstatectl show 2>&1" + expectedCommand := "nmstatectl show lo 2>&1" Expect(ds.Spec.Template.Spec.Containers[0].LivenessProbe.Exec.Command).To(ContainElement(expectedCommand)) }) }) diff --git a/deploy/handler/operator.yaml b/deploy/handler/operator.yaml index 3fbe3cf2c7..a678acf9ed 100644 --- a/deploy/handler/operator.yaml +++ b/deploy/handler/operator.yaml @@ -437,7 +437,7 @@ spec: command: - bash - -c - - "nmstatectl show {{ .HandlerReadinessProbeExtraArg }} 2>&1" + - "nmstatectl show lo {{ .HandlerReadinessProbeExtraArg }} 2>&1" initialDelaySeconds: 60 periodSeconds: 60 timeoutSeconds: 10 diff --git a/test/e2e/operator/nmstate_install_test.go b/test/e2e/operator/nmstate_install_test.go index f7394044a1..811406c6ad 100644 --- a/test/e2e/operator/nmstate_install_test.go +++ b/test/e2e/operator/nmstate_install_test.go @@ -198,7 +198,7 @@ var _ = Describe("NMState operator", func() { return false } - return slices.Contains(probe.Exec.Command, "nmstatectl show -vv 2>&1") + return slices.Contains(probe.Exec.Command, "nmstatectl show lo -vv 2>&1") }, 60*time.Second, 1*time.Second).Should(BeTrue(), "handler daemonset livenessProbe should use verbose flag") }) AfterEach(func() { @@ -247,10 +247,10 @@ var _ = Describe("NMState operator", func() { } for _, cmd := range probe.Exec.Command { - if cmd == "nmstatectl show -vv 2>&1" { + if cmd == "nmstatectl show lo -vv 2>&1" { return false // Should not have verbose flag in info mode } - if cmd == "nmstatectl show 2>&1" { + if cmd == "nmstatectl show lo 2>&1" { return true // Should have plain nmstatectl show command } } @@ -305,7 +305,7 @@ var _ = Describe("NMState operator", func() { } for _, cmd := range probe.Exec.Command { - if cmd == "nmstatectl show -vv 2>&1" { + if cmd == "nmstatectl show lo -vv 2>&1" { return true } }