Skip to content

test: don't delete namespaces in unit tests#854

Open
mandre wants to merge 1 commit into
k-orc:mainfrom
shiftstack:fix-unit-test-namespace-collision
Open

test: don't delete namespaces in unit tests#854
mandre wants to merge 1 commit into
k-orc:mainfrom
shiftstack:fix-unit-test-namespace-collision

Conversation

@mandre

@mandre mandre commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Namespace deletion is asynchronous — a deleted namespace enters a Terminating state before being fully removed. If the next test's GenerateName produces a suffix that collides with a still-Terminating namespace, the API server returns a hard error rather than retrying with a new name.

Since all unit tests run against an envtest API server that is torn down in AfterSuite, explicit namespace deletion is unnecessary. Remove the DeferCleanup blocks that delete namespaces to eliminate the flake.

Closes #850

Namespace deletion is asynchronous — a deleted namespace enters a
Terminating state before being fully removed. If the next test's
GenerateName produces a suffix that collides with a still-Terminating
namespace, the API server returns a hard error rather than retrying
with a new name.

Since all unit tests run against an envtest API server that is torn
down in AfterSuite, explicit namespace deletion is unnecessary. Remove
the DeferCleanup blocks that delete namespaces to eliminate the flake.

Closes k-orc#850
@github-actions github-actions Bot added the semver:patch No API change label Jul 17, 2026
@dlaw4608

Copy link
Copy Markdown
Contributor

Nice one LGTM, noticed the same namespace deletion is included in the upload_image.py file

Expect(k8sClient.Create(ctx, orcImage)).To(Succeed(), "create ORC Image")
DeferCleanup(func() {
Expect(k8sClient.Delete(ctx, namespace)).To(Succeed(), "delete ORC Image")
})
would it be worth it to carry the same rationale as above and let the envtest tear down handle deletion in AfterSuite in this case too, WDYT?

@winiciusallan

Copy link
Copy Markdown
Member

I think this partially solves the problem. When one test produces a suffix that clashes with an existing namespace, regardless it's being deleted or not, don't the apiserver return an error about trying to create an existing namespace?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:patch No API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI flaky: namespace collision in unit tests

3 participants