Skip to content

fix: use unique namespace suffix in cilium connectivity check verifier - #6438

Closed
Chai-bot (redhat-chai-bot) wants to merge 1 commit into
Azure:mainfrom
redhat-chai-bot:fix/cilium-connectivity-check-ns-suffix
Closed

fix: use unique namespace suffix in cilium connectivity check verifier#6438
Chai-bot (redhat-chai-bot) wants to merge 1 commit into
Azure:mainfrom
redhat-chai-bot:fix/cilium-connectivity-check-ns-suffix

Conversation

@redhat-chai-bot

Copy link
Copy Markdown
Collaborator

Problem

The VerifyCiliumConnectivityChecks verifier in test/util/verifiers/cilium.go hardcodes the namespace name as cilium-connectivity-check. When the verifier is invoked multiple times in the same test (as in cluster_create_feature_aggregation.go which calls it twice, once per nodepool), the second invocation fails because the namespace from the first invocation is still in Terminating state:

VerifyCiliumConnectivityChecks failed: failed to create test namespace:
object is being deleted: namespaces "cilium-connectivity-check" already exists

The cluster-scoped SecurityContextConstraints resource also has the name and users field hardcoded to reference the same namespace, causing a double collision.

Fix

  • Generate a unique 6-character random suffix for the namespace name on each invocation using rand.String(6) from k8s.io/apimachinery/pkg/util/rand, producing namespaces like cilium-connectivity-check-abc123.
  • Add an optional mutator hook to createArbitraryResource in helper.go (backward-compatible variadic parameter) so the SCC name and users service account path can be patched at load time to reference the dynamic namespace.
  • No changes to static YAML artifact files — mutation happens in Go at resource creation time.
  • Deferred cleanup needed no change — it already tracks sccNames and namespaceName dynamically.

Testing

  • go build ./... passes
  • go vet ./... passes

AI-generated. Review for accuracy.

David Eads (@deads2k) requested in Slack thread

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Cilium connectivity-check verifier to avoid namespace/SCC name collisions when the verifier is run multiple times within a single E2E test run (e.g., per-nodepool invocation), by generating a unique namespace name per invocation and mutating the embedded SCC manifest at creation time.

Changes:

  • Generate a unique namespace name per verifier run using a 6-character random suffix (cilium-connectivity-check-xxxxxx).
  • Add an optional variadic “mutator” hook to createArbitraryResource so callers can patch loaded YAML objects prior to creation.
  • Use the mutator hook in the Cilium verifier to rewrite the SCC metadata.name and users serviceaccount reference to the dynamic namespace.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/util/verifiers/helper.go Adds an optional mutator hook to allow patching unstructured resources before creating them.
test/util/verifiers/cilium.go Creates a unique namespace per run and rewrites the SCC manifest to match it to prevent collisions.

Comment thread test/util/verifiers/cilium.go Outdated
if obj.GetKind() != "SecurityContextConstraints" {
return nil
}
obj.SetName(namespaceName)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a suffix instead of replacing the name entirely.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — updated. The mutator now appends the suffix to the existing SCC name (obj.GetName() + "-" + suffix) instead of replacing it with namespaceName.


AI-generated. Review for accuracy.

@redhat-chai-bot
Chai-bot (redhat-chai-bot) force-pushed the fix/cilium-connectivity-check-ns-suffix branch from ac07e55 to 42dfd01 Compare August 5, 2026 16:32
Copilot AI review requested due to automatic review settings August 5, 2026 16:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@deads2k

Copy link
Copy Markdown
Collaborator

/lgtm

@redhat-chai-bot

Copy link
Copy Markdown
Collaborator Author

/retest-required


AI-generated. Review for accuracy.

@miquelsi

Copy link
Copy Markdown
Collaborator

/lgtm

Comment thread test/util/verifiers/cilium.go Outdated
obj.SetName(fmt.Sprintf("%s-%s", obj.GetName(), suffix))
return unstructured.SetNestedStringSlice(
obj.Object,
[]string{fmt.Sprintf("system:serviceaccount:%s:default", namespaceName)},

@mbukatov Martin Bukatovic (mbukatov) Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the original value from the yaml, and update just the name of the namespace instead of hard coding it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point — updated. The mutator now reads the original users entries via unstructured.NestedStringSlice and rewrites only the namespace portion of each system:serviceaccount:<ns>:<sa-name> reference, preserving the service account names and any non-service-account entries from the YAML.


AI-generated. Review for accuracy.

The cilium connectivity-check verifier hardcoded the namespace name
"cilium-connectivity-check". cluster_create_feature_aggregation.go invokes
VerifyCiliumConnectivityChecks once per nodepool. Namespace deletion is
asynchronous, so the second invocation could fail with "object is being
deleted: namespaces already exists" while the first namespace was still
terminating. The cluster-scoped SCC (name + service-account reference) was
hardcoded to the same name and collided too.

Generate a random suffix so each invocation uses a distinct
cilium-connectivity-check-<suffix> namespace, and rewrite the SCC name and
its users service-account reference to match via a mutator applied before
resource creation. Deferred cleanup already tracks the dynamic names.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 6, 2026 10:12
@redhat-chai-bot
Chai-bot (redhat-chai-bot) force-pushed the fix/cilium-connectivity-check-ns-suffix branch from 42dfd01 to 92606ab Compare August 6, 2026 10:12
@openshift-ci openshift-ci Bot removed the lgtm label Aug 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@redhat-chai-bot

Copy link
Copy Markdown
Collaborator Author

/retest-required


AI-generated. Review for accuracy.

1 similar comment
@redhat-chai-bot

Copy link
Copy Markdown
Collaborator Author

/retest-required


AI-generated. Review for accuracy.

@mbukatov

Copy link
Copy Markdown
Collaborator

/lgtm

@openshift-ci

openshift-ci Bot commented Aug 10, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, mbukatov, miquelsi, redhat-chai-bot

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@redhat-chai-bot

Copy link
Copy Markdown
Collaborator Author

/retest-required


AI-generated. Review for accuracy.

1 similar comment
@redhat-chai-bot

Copy link
Copy Markdown
Collaborator Author

/retest-required


AI-generated. Review for accuracy.

@miquelsi Miquel Simon (miquelsi) removed their assignment Aug 10, 2026
@miquelsi

Copy link
Copy Markdown
Collaborator

Addressed in #6460.

This PR can be closed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants