From a39be3f9e1dc2e97aff7093fddfe5f7dc1d99616 Mon Sep 17 00:00:00 2001 From: Marko Bevc Date: Tue, 5 May 2026 12:56:50 +0100 Subject: [PATCH] test(kube): tolerate IsNotFound on namespace cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AfterTest lists namespaces by label, then deletes each. A namespace from a previous test could still be in Terminating state when listed, then finish terminating before the Delete lands, returning NotFound. This caused the flaky failure in TestGetPodsDataWithThrottling on PR #858 (grpc 1.80→1.81 dependabot bump shifted timing enough to expose it). Skip NotFound errors on cleanup deletes — the namespace is gone, which is what we wanted. --- internal/kube/kube_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/kube/kube_test.go b/internal/kube/kube_test.go index f3036e8b3..f7ff6a3d4 100644 --- a/internal/kube/kube_test.go +++ b/internal/kube/kube_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" e2epod "k8s.io/kubernetes/test/e2e/framework/pod" "sigs.k8s.io/kind/pkg/cluster" @@ -64,6 +65,9 @@ func (suite *KubeTestSuite) AfterTest(_, _ string) { for _, ns := range namespaces.Items { err = suite.clientset.Clientset.CoreV1().Namespaces().Delete(ctx, ns.Name, metav1.DeleteOptions{}) + if apierrors.IsNotFound(err) { + continue + } require.NoErrorf(suite.T(), err, "error deleting namespace %s", ns.Name) } }