Skip to content

Introduce skip-name-validation flag and consolidate tests#7075

Merged
anhdle-sso merged 2 commits into
GoogleCloudPlatform:masterfrom
anhdle-sso:fix/skip-name-validation
Mar 18, 2026
Merged

Introduce skip-name-validation flag and consolidate tests#7075
anhdle-sso merged 2 commits into
GoogleCloudPlatform:masterfrom
anhdle-sso:fix/skip-name-validation

Conversation

@anhdle-sso

Copy link
Copy Markdown
Collaborator

BRIEF Change description

Introduce skip-name-validation flag to bypass duplicate controller name checks during registration and consolidate related tests.

WHY do we need this change?

In integration tests and certain multi-manager scenarios, creating multiple managers in the same process can lead to conflicts in controller-runtime's global controller name registry. This flag allows for opting out of that check when such conflicts are expected or managed.

Special notes for your reviewer:

Merged pkg/controller/kccmanager/kccmanager_skipnamevalidation_test.go into pkg/controller/kccmanager/kccmanager_test.go to maintain a cleaner package structure.
Ran make fmt to ensure proper code formatting.

Does this PR add something which needs to be 'release noted'?

Added a `--skip-name-validation` flag to Config Connector controllers to bypass duplicate controller name checks during registration.
  • Reviewer reviewed release note.

Additional documentation e.g., references, usage docs, etc.:

NONE

Intended Milestone

  • Reviewer tagged PR with the actual milestone.

Tests you have done

Ran all tests in pkg/controller/kccmanager package:
go test -v ./pkg/controller/kccmanager -tags=integration

  • Run make ready-pr to ensure this PR is ready for review.
  • Perform necessary E2E testing for changed resources.

This change introduces a 'skip-name-validation' flag across various controllers to bypass the duplicate controller name check during registration. This is particularly useful for integration tests where multiple managers might be created in the same process, avoiding conflicts in controller-runtime's global name registry.

Additionally, consolidated 'kccmanager_skipnamevalidation_test.go' into 'kccmanager_test.go'.
Comment thread pkg/controller/kccmanager/kccmanager_test.go
Comment thread pkg/controller/config.go Outdated
Comment thread pkg/controller/direct/directbase/directbase_controller.go Outdated
Comment thread pkg/controller/registration/registration_controller.go Outdated
Comment thread config/tests/samples/create/harness.go
Comment thread pkg/controller/deletiondefender/controller.go
Comment thread pkg/controller/iam/auditconfig/iamauditconfig_controller.go
Comment thread cmd/manager/main.go Outdated
Comment thread pkg/controller/gsakeysecretgenerator/gsakey_secret_generator.go Outdated
Comment thread pkg/controller/registration/registration_controller.go
- Use k8s.io/utils/ptr.To instead of taking address of struct fields for controller options.
- Clarify SkipNameValidation comments and flag description.
- Add note about global state in controller-runtime during tests.

@cheftako cheftako left a comment

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.

Approving for now. Lets get these cleaned up soon.

flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
flag.BoolVar(&enablePprof, "enable-pprof", false, "Enable the pprof server.")
flag.IntVar(&pprofPort, "pprof-port", 6060, "The port that the pprof server binds to if enabled.")
flag.BoolVar(&skipNameValidation, "skip-name-validation", false, "option to bypass the duplicate controller name check during registration; false by default")

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.

Nit: Dislike booleans in APIs. Also not sure why we need this control in the deletion defender.

// Register the registration controller, which will dynamically create controllers for
// all our resources.
if err := registration.AddDeletionDefender(mgr, &controller.Deps{}); err != nil {
if err := registration.AddDeletionDefender(mgr, &controller.Deps{SkipNameValidation: skipNameValidation}); err != nil {

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.

Nit: Seems like we can just pass false here.

Comment thread cmd/manager/main.go
flag.Float32Var(&rateLimitQps, "qps", 20.0, "The client-side token bucket rate limit qps.")
flag.IntVar(&rateLimitBurst, "burst", 30, "The client-side token bucket rate limit burst.")
flag.StringVar(&leaderElectionMode, "leader-election-type", "disabled", "Leader election mode. One of: default, multicluster.")
flag.BoolVar(&skipNameValidation, "skip-name-validation", false, "option to bypass the global controller name registry in controller-runtime; false by default")

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.

Nit: Dislike booleans in APIs. Also not sure why we need this control in the manager? Seems like we are running the manager from cli tool. We should chat about this. In a 10K namespace cluster, I don't think its safe to spin up 10K pods. I would rather have this run in process and take longer.

flag.BoolVar(&enablePprof, "enable-pprof", false, "Enable the pprof server.")
flag.IntVar(&pprofPort, "pprof-port", 6060, "The port that the pprof server binds to if enabled.")
flag.StringVar(&managerNamespaceIsolation, k8s.ManagerNamespaceIsolationFlag, k8s.ManagerNamespaceIsolationShared, fmt.Sprintf("'%s' if all controller managers run in shared 'cnrm-system' namespace, '%s' if controller managers run in dedicated namespace. Default is '%s'", k8s.ManagerNamespaceIsolationShared, k8s.ManagerNamespaceIsolationDedicated, k8s.ManagerNamespaceIsolationShared))
flag.BoolVar(&skipNameValidation, "skip-name-validation", false, "option to bypass the duplicate controller name check during registration; false by default")

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.

Nit: Dislike booleans in APIs. Also not sure why we need this control in the unmanaged detector? Lets get a bug going and clean this up before 1.48


func Add(mgr manager.Manager, crd *apiextensions.CustomResourceDefinition) error {
func Add(mgr manager.Manager, crd *apiextensions.CustomResourceDefinition, opt controller.Options) error {
if opt.MaxConcurrentReconciles == 0 {

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.

NIT: Should probably be <= 0. Assuming we not support negatives.

// add adds a new Controller to mgr with r as the reconcile.Reconciler.
func add(mgr manager.Manager, r *Reconciler) error {
func add(mgr manager.Manager, r *Reconciler, opt controller.Options) error {
if opt.MaxConcurrentReconciles == 0 {

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.

NIT: <= 0

// add adds a new Controller to mgr with r as the reconcile.Reconciler.
func add(mgr manager.Manager, r *ReconcileIAMPolicy) error {
func add(mgr manager.Manager, r *ReconcileIAMPolicy, opt controller.Options) error {
if opt.MaxConcurrentReconciles == 0 {

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.

NIT: <= 0

// add adds a new Controller to mgr with r as the reconcile.Reconciler.
func add(mgr manager.Manager, r *Reconciler) error {
func add(mgr manager.Manager, r *Reconciler, opt controller.Options) error {
if opt.MaxConcurrentReconciles == 0 {

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.

NIT: <= 0

func Add(ctx context.Context, mgr manager.Manager, gvk schema.GroupVersionKind, opt controller.Options) error {
logger := crlog.FromContext(ctx)

if opt.MaxConcurrentReconciles == 0 {

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.

<= 0

@google-oss-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheftako

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

@anhdle-sso anhdle-sso added this pull request to the merge queue Mar 17, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 18, 2026
@anhdle-sso anhdle-sso added this pull request to the merge queue Mar 18, 2026
Merged via the queue into GoogleCloudPlatform:master with commit 3a7898e Mar 18, 2026
166 checks passed
@cheftako cheftako added this to the 1.148 milestone Mar 20, 2026
cheftako added a commit that referenced this pull request Mar 20, 2026
This PR cherry-picks the changes from PR #7075 to the release-1.147
branch
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.

2 participants