Skip to content

test(kube): tolerate IsNotFound on namespace cleanup#860

Merged
mbevc1 merged 1 commit intomainfrom
20260505_fix_kube_testing
May 6, 2026
Merged

test(kube): tolerate IsNotFound on namespace cleanup#860
mbevc1 merged 1 commit intomainfrom
20260505_fix_kube_testing

Conversation

@mbevc1
Copy link
Copy Markdown
Contributor

@mbevc1 mbevc1 commented May 5, 2026

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 (it shifted timing enough to expose it).

Skip NotFound errors on cleanup deletes — the namespace is gone, which is the intent.

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.
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 5, 2026

Claude finished @mbevc1's task in 1m 30s —— View job


PR Review: test(kube): tolerate IsNotFound on namespace cleanup

  • Phase 1: Static analysis (go build, go vet, go mod tidy)
  • Phase 2: Code review
  • Phase 3: Post review feedback

Static analysis: All clear — go build ./..., go vet ./..., and go mod tidy all pass with no issues.

Review: This is a clean, correct fix for a real race condition in test cleanup.

The problem is well-described: AfterTest lists namespaces by label, iterates, and deletes each one. A namespace already in Terminating state can disappear between the List and the Delete, causing a spurious NotFound error that fails an unrelated test. Guarding with apierrors.IsNotFound is the idiomatic Kubernetes pattern for this exact scenario.

The change is minimal (4 lines), correctly scoped to test infrastructure only, and doesn't affect production code. The continue skips only NotFound — all other errors still hit require.NoErrorf and fail loudly. No notes.

LGTM 👍

@mbevc1 mbevc1 enabled auto-merge (squash) May 5, 2026 12:02
@mbevc1 mbevc1 merged commit ed9e540 into main May 6, 2026
20 checks passed
@mbevc1 mbevc1 deleted the 20260505_fix_kube_testing branch May 6, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants