← Back to Pull requests

fix(kccmanager): only generate syncer rules for served kinds with service-generated IDs #16446

Merged
lovelace-coder-bot merged 7 files (485 lines) on Nov 26, 2026 23:56 UTC
View on GitHub
lovelace-coder-bot lovelace-coder-bot commented on Nov 25, 2026 06:32 UTC
Author

This pull request was generated by an AI coding agent.

In multi-cluster HA setups using Status replication, KRMSyncer generated rules for all 68 kinds in syncerGVKsWithServiceGeneratedIDs regardless of whether the cluster served those kinds. In release installations, CRDs that only have alpha versions are not installed, yet rules were generated for them. The standby syncer attempts to start remote watches on the leader for every kind named in its rules, causing cache sync timeouts and repeated process exits after two minutes.

This change:

  • Adds a discovery client to SyncerIntegration with a 10-second timeout to query served kinds from the API server.

  • Filters syncerGVKsWithServiceGeneratedIDs so that KRMSyncer rules are generated only for kinds actually served by the cluster.

  • Bypasses discovery calls in Full replication mode where objects are copied in full.

  • Adds unit tests for discovery filtering, error handling, and Full mode bypass.

  • Adds an envtest test verifying that KRMSyncer rules for a kind on the list are only generated once its CRD is installed.
  • Fixes #16395

    ``release-note
    Fix standby KRMSyncer crash loops in multi-cluster HA setups by only generating syncer rules for served kinds with service-generated IDs.
    ``

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-fix-20261125-045429-3d46 -->

    Diff: 485 lines (+471 / -14) across 7 files Reviewer: acpana Review duration: 2484m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.49) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.49 · 485 lines diff across 7 files
    0.49
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.81 · 5 substantive comment(s)
    0.81
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    82%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.370
    Real PR Conversation Timeline
    21 items
    argus-watcher-bot argus-watcher-bot commented on Nov 25, 2026 06:49 UTC
    Bot

    🤖 AI Factory started investigating CI check failures for this pull request.

    Note: We recommend waiting for the 'ready-for-human' label before leaving review comments. Comments added while the system is actively working may be associated with outdated commits once a new commit is pushed, causing them to be ignored.

    lovelace-coder-bot lovelace-coder-bot commented on Nov 25, 2026 07:01 UTC
    Author

    An AI coding agent updated the pull request description to add the required ``release-note`` block. The "Validate PR Release Note" check failed because the initial description omitted the release note section. All code changes and presubmit tests remain unmodified and passing.

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-care-ci-20261125-064926-241d -->

    argus-watcher-bot argus-watcher-bot commented on Nov 25, 2026 09:03 UTC
    Bot

    🤖 AI Factory started investigating CI check failures for this pull request.

    Note: We recommend waiting for the 'ready-for-human' label before leaving review comments. Comments added while the system is actively working may be associated with outdated commits once a new commit is pushed, causing them to be ignored.

    lovelace-coder-bot lovelace-coder-bot commented on Nov 25, 2026 09:40 UTC
    Author

    An AI coding agent rebased the branch onto latest upstream master to incorporate recent upstream changes and clear the stale failed "Validate PR Release Note" check from the previous commit. The pull request description already contains a valid release-note block, and all unit and E2E tests in pkg/controller/kccmanager/... continue to pass.

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-care-ci-20261125-090714-b6c6 -->

    acpana acpana commented on code on Nov 26, 2026 19:47 UTC
    Code Review
    pkg/controller/kccmanager/syncer_integration_e2e_test.go:1
    @@ -196,6 +210,130 @@ func TestSyncerIntegration_RemoteFollowsLeader(t *testing.T) {
     	}
     }
     
    +// The KRMSyncer gets a kind's rule when the kind's CRD is installed, and not before.
    +func TestSyncerIntegration_RulesOnlyForServedKinds(t *testing.T) {
    +	ctx := context.Background()
    +	cfg, kubeClient := startSyncerEnvtest(t)
    +
    +	syncerDiscovery, err := newSyncerDiscovery(cfg)
    +	if err != nil {
    +		t.Fatalf("error creating discovery client: %v", err)
    +	}
    +
    +	ns := "cnrm-system"
    +	if err := kubeClient.Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ns}}); err != nil {
    +		t.Fatalf("error creating namespace: %v", err)
    +	}
    +
    +	self := testGKECluster("cluster-standby")
    +	nn := types.NamespacedName{Namespace: ns, Name: "test-lease"}
    +	si := &SyncerIntegration{
    +		client:          kubeClient,
    +		apiReader:       kubeClient,
    +		discovery:       syncerDiscovery,
    +		leaseNN:         nn,
    +		replicationMode: "Status",
    +		cluster:         self,
    +	}
    +
    +	getSyncer := func() *unstructured.Unstructured {
    +		t.Helper()
    +		u := &unstructured.Unstructured{}
    +		u.SetGroupVersionKind(KRMSyncerGVK)
    +		if err := kubeClient.Get(ctx, nn, u); err != nil {
    +			t.Fatalf("error getting KRMSyncer %s: %v", nn, err)
    +		}
    +		return u
    +	}
    +
    +	// This cluster is a standby: the KRMSyncer is created.
    +	leader := testGKECluster("cluster-leader")
    +	if err := si.EnsurePullingFromLeader(ctx, leader); err != nil {
    +		t.Fatalf("EnsurePullingFromLeader: %v", err)
    +	}
    +
    +	// Before installing any CRD on the service-generated list, only the generic glob rule is present.
    +	rules, _, _ := unstructured.NestedSlice(getSyncer().Object, "spec", "rules")
    +	if len(rules) != 1 {
    +		t.Fatalf("expected exactly 1 rule before installing CRD, got %d rules: %v", len(rules), rules)
    +	}
    +
    +	// Install a CRD for Folder (resourcemanager.cnrm.cloud.google.com/v1beta1).
    +	folderCRD := &apiextensionsv1.CustomResourceDefinition{
    +		ObjectMeta: metav1.ObjectMeta{
    +			Name: "folders.resourcemanager.cnrm.cloud.google.com",
    +		},
    +		Spec: apiextensionsv1.CustomResourceDefinitionSpec{
    +			Group: "resourcemanager.cnrm.cloud.google.com",
    +			Names: apiextensionsv1.CustomResourceDefinitionNames{
    +				Plural:   "folders",
    +				Singular: "folder",
    +				Kind:     "Folder",
    +			},
    +			Scope: apiextensionsv1.ClusterScoped,
    +			Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
    +				{
    +					Name:    "v1beta1",
    +					Served:  true,
    +					Storage: true,
    +					Schema: &apiextensionsv1.CustomResourceValidation{
    +						OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{
    +							Type: "object",
    +						},
    +					},
    +				},
    +			},
    +		},
    +	}
    +	if err := kubeClient.Create(ctx, folderCRD); err != nil {
    +		t.Fatalf("error creating Folder CRD: %v", err)
    +	}
    +
    +	// Wait until discovery sees the new CRD.
    +	if err := wait.PollUntilContextTimeout(ctx, 50*time.Millisecond, 10*time.Second, true, func(ctx context.Context) (bool, error) {
    +		gvks, err := si.servedGVKsWithServiceGeneratedIDs()
    +		if err != nil {
    +			return false, err
    +		}
    +		for _, gvk := range gvks {
    +			if gvk.Kind == "Folder" {
    +				return true, nil
    +			}
    +		}
    +		return false, nil
    +	}); err != nil {
    +		t.Fatalf("timed out waiting for Folder CRD to be discovered: %v", err)
    +	}
    +
    +	// Update the syncer with EnsurePullingFromLeader.
    +	if err := si.EnsurePullingFromLeader(ctx, leader); err != nil {
    +		t.Fatalf("EnsurePullingFromLeader after installing CRD: %v", err)
    +	}
    +
    +	// Now the KRMSyncer has 2 rules: the glob rule and the Folder rule.
    +	rules, _, _ = unstructured.NestedSlice(getSyncer().Object, "spec", "rules")
    +	if len(rules) != 2 {
    +		t.Fatalf("expected 2 rules after installing CRD, got %d: %v", len(rules), rules)
    +	}
    +	foundFolderRule := false
    +	for _, r := range rules {
    +		ruleMap, ok := r.(map[string]interface{})
    +		if !ok {
    +			continue
    +		}
    +		if ruleMap["kind"] == "Folder" && ruleMap["group"] == "resourcemanager.cnrm.cloud.google.com" && ruleMap["version"] == "v1beta1" {
    +			foundFolderRule = true
    +			syncFields, _, _ := unstructured.NestedSlice(ruleMap, "syncFields")
    +			if len(syncFields) != 2 || syncFields[0] != "status" || syncFields[1] != "spec.resourceID" {
    +				t.Errorf("unexpected syncFields for Folder rule: %v", syncFields)
    +			}
    +		}
    +	}
    +	if !foundFolderRule {
    +		t.Errorf("Folder rule not found in syncer rules: %v", rules)
    +	}
    +}

    Could we also call si.EnsureSuspended(ctx) at the end of TestSyncerIntegration_RulesOnlyForServedKinds and assert len(rules) == 2 (with suspend == true)? All other tests that call EnsureSuspended run with zero KCC resource CRDs installed, so right now passing nil instead of gvksWithOwnRule in EnsureSuspended passes the entire test suite.

    acpana acpana commented on code on Nov 26, 2026 19:47 UTC
    Code Review
    pkg/controller/kccmanager/syncer_integration_test.go:1
    @@ -96,17 +101,148 @@ func TestGetNamespacesForSyncer(t *testing.T) {
     	}
     }
     
    +type fakeDiscovery struct {
    +	groups    []*metav1.APIGroup
    +	resources []*metav1.APIResourceList
    +	err       error
    +}
    +
    +func (f *fakeDiscovery) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) {
    +	return f.groups, f.resources, f.err
    +}
    +
    +func TestServedGVKsWithServiceGeneratedIDs(t *testing.T) {
    +	// 1. Not initialized
    +	siUninit := &SyncerIntegration{}
    +	if _, err := siUninit.servedGVKsWithServiceGeneratedIDs(); err == nil || !strings.Contains(err.Error(), "discovery client not initialized") {
    +		t.Fatalf("expected 'discovery client not initialized', got %v", err)
    +	}
    +
    +	// 2. Served and unserved kinds, two served versions of one kind, subresources, and kinds not on list
    +	fake := &fakeDiscovery{
    +		resources: []*metav1.APIResourceList{
    +			{
    +				GroupVersion: "resourcemanager.cnrm.cloud.google.com/v1beta1",
    +				APIResources: []metav1.APIResource{
    +					{Name: "folders", Kind: "Folder"},
    +					{Name: "folders/status", Kind: "Folder"}, // Subresource should be ignored
    +					{Name: "projects", Kind: "Project"},      // Not in syncerGVKsWithServiceGeneratedIDs
    +				},

    Two small unit-test tightening suggestions:

    1. Subresource skip in TestServedGVKsWithServiceGeneratedIDs: Because {Name: "folders", Kind: "Folder"} is present right above {Name: "folders/status", Kind: "Folder"} and servedSet deduplicates by GVK, removing if strings.Contains(resource.Name, "/") { continue } in servedGVKsWithServiceGeneratedIDs still passes this test. Adding a subresource entry whose Kind is in syncerGVKsWithServiceGeneratedIDs without its parent resource (e.g. {Name: "folders/liens", Kind: "ResourceManagerLien"}) ensures the / check is actually exercised.
    2. Unit test newSyncerDiscovery: Adding a small TestNewSyncerDiscovery that passes a &rest.Config{Host: "https://example.com", Timeout: 42 time.Second} and checks that (a) the caller's cfg.Timeout stays 42s (not mutated in place) and (b) the returned discovery.DiscoveryClient's underlying *rest.RESTClient has Client.Timeout == syncerDiscoveryTimeout (10s) pins the timeout isolation that leaderFollower.stop relies on.

    acpana acpana commented on Nov 26, 2026 19:47 UTC
    Reviewer

    address feebdack

    argus-watcher-bot argus-watcher-bot commented on Nov 26, 2026 19:56 UTC
    Bot

    🤖 AI Factory started addressing review feedback for this pull request.

    lovelace-coder-bot lovelace-coder-bot commented on code on Nov 26, 2026 20:18 UTC
    Code Review
    pkg/controller/kccmanager/syncer_integration_e2e_test.go:1
    @@ -196,6 +210,130 @@ func TestSyncerIntegration_RemoteFollowsLeader(t *testing.T) {
     	}
     }
     
    +// The KRMSyncer gets a kind's rule when the kind's CRD is installed, and not before.
    +func TestSyncerIntegration_RulesOnlyForServedKinds(t *testing.T) {
    +	ctx := context.Background()
    +	cfg, kubeClient := startSyncerEnvtest(t)
    +
    +	syncerDiscovery, err := newSyncerDiscovery(cfg)
    +	if err != nil {
    +		t.Fatalf("error creating discovery client: %v", err)
    +	}
    +
    +	ns := "cnrm-system"
    +	if err := kubeClient.Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ns}}); err != nil {
    +		t.Fatalf("error creating namespace: %v", err)
    +	}
    +
    +	self := testGKECluster("cluster-standby")
    +	nn := types.NamespacedName{Namespace: ns, Name: "test-lease"}
    +	si := &SyncerIntegration{
    +		client:          kubeClient,
    +		apiReader:       kubeClient,
    +		discovery:       syncerDiscovery,
    +		leaseNN:         nn,
    +		replicationMode: "Status",
    +		cluster:         self,
    +	}
    +
    +	getSyncer := func() *unstructured.Unstructured {
    +		t.Helper()
    +		u := &unstructured.Unstructured{}
    +		u.SetGroupVersionKind(KRMSyncerGVK)
    +		if err := kubeClient.Get(ctx, nn, u); err != nil {
    +			t.Fatalf("error getting KRMSyncer %s: %v", nn, err)
    +		}
    +		return u
    +	}
    +
    +	// This cluster is a standby: the KRMSyncer is created.
    +	leader := testGKECluster("cluster-leader")
    +	if err := si.EnsurePullingFromLeader(ctx, leader); err != nil {
    +		t.Fatalf("EnsurePullingFromLeader: %v", err)
    +	}
    +
    +	// Before installing any CRD on the service-generated list, only the generic glob rule is present.
    +	rules, _, _ := unstructured.NestedSlice(getSyncer().Object, "spec", "rules")
    +	if len(rules) != 1 {
    +		t.Fatalf("expected exactly 1 rule before installing CRD, got %d rules: %v", len(rules), rules)
    +	}
    +
    +	// Install a CRD for Folder (resourcemanager.cnrm.cloud.google.com/v1beta1).
    +	folderCRD := &apiextensionsv1.CustomResourceDefinition{
    +		ObjectMeta: metav1.ObjectMeta{
    +			Name: "folders.resourcemanager.cnrm.cloud.google.com",
    +		},
    +		Spec: apiextensionsv1.CustomResourceDefinitionSpec{
    +			Group: "resourcemanager.cnrm.cloud.google.com",
    +			Names: apiextensionsv1.CustomResourceDefinitionNames{
    +				Plural:   "folders",
    +				Singular: "folder",
    +				Kind:     "Folder",
    +			},
    +			Scope: apiextensionsv1.ClusterScoped,
    +			Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
    +				{
    +					Name:    "v1beta1",
    +					Served:  true,
    +					Storage: true,
    +					Schema: &apiextensionsv1.CustomResourceValidation{
    +						OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{
    +							Type: "object",
    +						},
    +					},
    +				},
    +			},
    +		},
    +	}
    +	if err := kubeClient.Create(ctx, folderCRD); err != nil {
    +		t.Fatalf("error creating Folder CRD: %v", err)
    +	}
    +
    +	// Wait until discovery sees the new CRD.
    +	if err := wait.PollUntilContextTimeout(ctx, 50*time.Millisecond, 10*time.Second, true, func(ctx context.Context) (bool, error) {
    +		gvks, err := si.servedGVKsWithServiceGeneratedIDs()
    +		if err != nil {
    +			return false, err
    +		}
    +		for _, gvk := range gvks {
    +			if gvk.Kind == "Folder" {
    +				return true, nil
    +			}
    +		}
    +		return false, nil
    +	}); err != nil {
    +		t.Fatalf("timed out waiting for Folder CRD to be discovered: %v", err)
    +	}
    +
    +	// Update the syncer with EnsurePullingFromLeader.
    +	if err := si.EnsurePullingFromLeader(ctx, leader); err != nil {
    +		t.Fatalf("EnsurePullingFromLeader after installing CRD: %v", err)
    +	}
    +
    +	// Now the KRMSyncer has 2 rules: the glob rule and the Folder rule.
    +	rules, _, _ = unstructured.NestedSlice(getSyncer().Object, "spec", "rules")
    +	if len(rules) != 2 {
    +		t.Fatalf("expected 2 rules after installing CRD, got %d: %v", len(rules), rules)
    +	}
    +	foundFolderRule := false
    +	for _, r := range rules {
    +		ruleMap, ok := r.(map[string]interface{})
    +		if !ok {
    +			continue
    +		}
    +		if ruleMap["kind"] == "Folder" && ruleMap["group"] == "resourcemanager.cnrm.cloud.google.com" && ruleMap["version"] == "v1beta1" {
    +			foundFolderRule = true
    +			syncFields, _, _ := unstructured.NestedSlice(ruleMap, "syncFields")
    +			if len(syncFields) != 2 || syncFields[0] != "status" || syncFields[1] != "spec.resourceID" {
    +				t.Errorf("unexpected syncFields for Folder rule: %v", syncFields)
    +			}
    +		}
    +	}
    +	if !foundFolderRule {
    +		t.Errorf("Folder rule not found in syncer rules: %v", rules)
    +	}
    +}

    An AI coding agent updated TestSyncerIntegration_RulesOnlyForServedKinds to call si.EnsureSuspended(ctx) at the end and assert len(rules) == 2 along with spec.suspend == true.

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-care-comments-20261126-195830-0140 reply=4712804465 -->

    lovelace-coder-bot lovelace-coder-bot commented on code on Nov 26, 2026 20:18 UTC
    Code Review
    pkg/controller/kccmanager/syncer_integration_test.go:1
    @@ -96,17 +101,148 @@ func TestGetNamespacesForSyncer(t *testing.T) {
     	}
     }
     
    +type fakeDiscovery struct {
    +	groups    []*metav1.APIGroup
    +	resources []*metav1.APIResourceList
    +	err       error
    +}
    +
    +func (f *fakeDiscovery) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) {
    +	return f.groups, f.resources, f.err
    +}
    +
    +func TestServedGVKsWithServiceGeneratedIDs(t *testing.T) {
    +	// 1. Not initialized
    +	siUninit := &SyncerIntegration{}
    +	if _, err := siUninit.servedGVKsWithServiceGeneratedIDs(); err == nil || !strings.Contains(err.Error(), "discovery client not initialized") {
    +		t.Fatalf("expected 'discovery client not initialized', got %v", err)
    +	}
    +
    +	// 2. Served and unserved kinds, two served versions of one kind, subresources, and kinds not on list
    +	fake := &fakeDiscovery{
    +		resources: []*metav1.APIResourceList{
    +			{
    +				GroupVersion: "resourcemanager.cnrm.cloud.google.com/v1beta1",
    +				APIResources: []metav1.APIResource{
    +					{Name: "folders", Kind: "Folder"},
    +					{Name: "folders/status", Kind: "Folder"}, // Subresource should be ignored
    +					{Name: "projects", Kind: "Project"},      // Not in syncerGVKsWithServiceGeneratedIDs
    +				},

    An AI coding agent addressed both suggestions:
    1. Added {Name: "folders/liens", Kind: "ResourceManagerLien"} to TestServedGVKsWithServiceGeneratedIDs to exercise the subresource filter against a kind on the service-generated list without its parent resource.
    2. Added TestNewSyncerDiscovery to verify that newSyncerDiscovery leaves the caller's rest.Config.Timeout untouched while configuring Client.Timeout == syncerDiscoveryTimeout (10s) on the underlying RESTClient.

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-care-comments-20261126-195830-0140 reply=4712807837 -->

    lovelace-coder-bot lovelace-coder-bot commented on Nov 26, 2026 20:18 UTC
    Author

    An AI coding agent addressed review feedback from @acpana by tightening unit tests and expanding e2e assertions:

  • Added an EnsureSuspended assertion to TestSyncerIntegration_RulesOnlyForServedKinds to verify that EnsureSuspended preserves served GVK rules with suspend == true.

  • Added {Name: "folders/liens", Kind: "ResourceManagerLien"} to TestServedGVKsWithServiceGeneratedIDs to test the subresource check in isolation.

  • Added TestNewSyncerDiscovery to test config timeout isolation.
  • <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-care-comments-20261126-195830-0140 -->

    argus-watcher-bot argus-watcher-bot commented on Nov 26, 2026 20:28 UTC
    Bot

    🤖 AI Factory started investigating CI check failures for this pull request.

    Note: We recommend waiting for the 'ready-for-human' label before leaving review comments. Comments added while the system is actively working may be associated with outdated commits once a new commit is pushed, causing them to be ignored.

    lovelace-coder-bot lovelace-coder-bot commented on Nov 26, 2026 20:29 UTC
    Author

    An AI coding agent inspected the failing tests-e2e-samples-bigquerydatapolicy check on workflow run 45890044334. The failure occurred during the actions/setup-go step due to a network TLS handshake timeout while downloading the Go toolchain. No code changes were needed because the failure was caused by transient runner infrastructure issues. Requesting a rerun of workflow run 45890044334.

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-care-ci-20261126-202821-8e2e -->

    lovelace-coder-bot lovelace-coder-bot commented on Nov 26, 2026 20:29 UTC
    Author

    🤖 These checks failed through no fault of this change, so their failed jobs are to be re-run. Run 45890044334 (ci-presubmit) is still running, and GitHub reruns a run only once it has finished: its failed jobs will be re-run when it does.

    <!-- factory:deferred action=rerun run=45890044334 head=77fe094e0a2cd8acd12636830b54a0183e06ffcc until=2026-11-26T22:29:48Z state=pending -->

    acpana acpana commented on Nov 26, 2026 21:46 UTC
    Contributor

    Thanks, the three test changes do what I asked for. I checked each by breaking the code it guards, and each now fails a test.

    CI is red on this commit, and that needs a change here, not a re-run. unit-tests-4-of-4 has failed in all three attempts, each time in TestStandbyKeepsLeaderResourceID:

    syncer_resourceid_test.go:270: error configuring the KRMSyncer: discovery client not initialized
    

    That test isn't on this branch. It came in with #16432, which merged to master after this branch was cut, and CI tests the merge of the branch with master. The test builds a SyncerIntegration without discovery, which this PR requires in Status mode. Git merges the two without a conflict, so the PR still shows as mergeable.

    Please update the branch from master and give that SyncerIntegration a discovery client, as the other tests in this PR do:

    	// The KRMSyncer, as the manager of a standby writes it.
    	syncerDiscovery, err := newSyncerDiscovery(standbyCfg)
    	if err != nil {
    		t.Fatalf("error creating discovery client: %v", err)
    	}
    	si := &SyncerIntegration{
    		client:          standby,
    		apiReader:       standby,
    		discovery:       syncerDiscovery,
    		leaseNN:         types.NamespacedName{Namespace: "cnrm-system", Name: "kcc-multicluster-lease"},
    		replicationMode: "Status",
    		cluster:         testGKECluster("standby"),
    	}
    

    With this change, all 23 tests of the package pass for me on the merge with current master (5cce7c7ea9).

    argus-watcher-bot argus-watcher-bot commented on Nov 26, 2026 21:50 UTC
    Bot

    🤖 AI Factory started addressing review feedback for this pull request.

    lovelace-coder-bot lovelace-coder-bot commented on Nov 26, 2026 22:02 UTC
    Author

    Thanks, the three test changes do what I asked for. I checked each by breaking the code it guards, and each now fails a test.

    > CI is red on this commit, and that needs a change here, not a re-run. unit-tests-4-of-4 has failed in all three attempts, each time in TestStandbyKeepsLeaderResourceID:

    …

    In reply to @acpana

    An AI coding agent updated the branch from upstream master (5cce7c7ea9) and updated TestStandbyKeepsLeaderResourceID to initialize and provide a discovery client via newSyncerDiscovery(standbyCfg) to SyncerIntegration. All 23 tests in pkg/controller/kccmanager are now passing.

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-care-comments-20261126-215404-a691 reply=7204039398 -->

    lovelace-coder-bot lovelace-coder-bot commented on Nov 26, 2026 22:02 UTC
    Author

    An AI coding agent rebased the branch onto latest upstream master (5cce7c7ea9) to incorporate #16432 and updated TestStandbyKeepsLeaderResourceID to initialize SyncerIntegration with a discovery client, resolving the failure in unit-tests-4-of-4.

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-care-comments-20261126-215404-a691 -->

    acpana acpana approved these changes on Nov 26, 2026 23:17 UTC
    Approved Reviewer

    Approved these changes.

    google-oss-prow[bot] google-oss-prow[bot] commented on Nov 26, 2026 23:18 UTC
    Bot

    [APPROVALNOTIFIER] This PR is APPROVED

    This pull-request has been approved by: <a href="https://github.com/GoogleCloudPlatform/k8s-config-connector/pull/16446#pullrequestreview-6081406759" title="Approved">acpana</a>

    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:

  • ~~OWNERS~~ [acpana]
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":[]} -->

    Reviewers
    Assignees
    lovelace-coder-bot lovelace-coder-bot
    Labels
    risk: low confidence: 82.6% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.8% (MEDIUM) · Higher = larger blast radius
    48.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 82.6% · Lower = rushed or shallow review
    82.6%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.5% · Safe to merge
    8.5%