From 1ba5c1a6ddf5b34a58c402e20d69214004f41d26 Mon Sep 17 00:00:00 2001 From: Martin Gencur Date: Tue, 23 Jun 2026 10:55:30 +0200 Subject: [PATCH] fix(test): add retry logic to GetLogs in Karpenter kubelet propagation test The kubelet serving certificate on freshly provisioned Karpenter nodes may not be ready immediately after the node is marked Ready, causing transient "tls: internal error" or "http2: client connection lost" failures on the proxied log request. Wrap the GetLogs call in g.Eventually with a 2-minute timeout to tolerate this window. Co-Authored-By: Claude Opus 4.6 --- test/e2e/karpenter_test.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/test/e2e/karpenter_test.go b/test/e2e/karpenter_test.go index 09599c9ca6ab..e74a436b9afd 100644 --- a/test/e2e/karpenter_test.go +++ b/test/e2e/karpenter_test.go @@ -1325,13 +1325,19 @@ func testKubeletPropagation(ctx context.Context, mgtClient, guestClient crclient g.Expect(p.Status.Phase).To(BeElementOf(corev1.PodSucceeded, corev1.PodFailed)) }).WithTimeout(5 * time.Minute).WithPolling(5 * time.Second).Should(Succeed()) - // Always fetch and log the pod output so it's visible in the test run - logReq := guestClientset.CoreV1().Pods(checkerPod.Namespace).GetLogs(checkerPod.Name, &corev1.PodLogOptions{Container: "checker"}) - logStream, err := logReq.Stream(ctx) - g.Expect(err).NotTo(HaveOccurred()) - defer logStream.Close() - logBytes, err := io.ReadAll(logStream) - g.Expect(err).NotTo(HaveOccurred()) + // Fetch pod output with retries — the kubelet serving cert on freshly + // provisioned Karpenter nodes may not be ready immediately after the + // node is marked Ready, causing transient TLS or HTTP/2 errors on the + // proxied log request. + var logBytes []byte + g.Eventually(func(g Gomega) { + logReq := guestClientset.CoreV1().Pods(checkerPod.Namespace).GetLogs(checkerPod.Name, &corev1.PodLogOptions{Container: "checker"}) + logStream, err := logReq.Stream(ctx) + g.Expect(err).NotTo(HaveOccurred()) + defer logStream.Close() + logBytes, err = io.ReadAll(logStream) + g.Expect(err).NotTo(HaveOccurred()) + }).WithTimeout(2 * time.Minute).WithPolling(10 * time.Second).Should(Succeed()) t.Logf("kubelet-config-checker output:\n%s", string(logBytes)) // Assert the pod succeeded (grep chain exited 0 = all fields found)