fix(kccmanager): only generate syncer rules for served kinds with service-generated IDs #16446
🤖 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.
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 -->
🤖 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.
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 -->
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.
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.
address feebdack
🤖 AI Factory started addressing review feedback for this pull request.
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 -->
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 -->
An AI coding agent addressed review feedback from @acpana by tightening unit tests and expanding e2e assertions:
EnsureSuspended assertion to TestSyncerIntegration_RulesOnlyForServedKinds to verify that EnsureSuspended preserves served GVK rules with suspend == true.{Name: "folders/liens", Kind: "ResourceManagerLien"} to TestServedGVKsWithServiceGeneratedIDs to test the subresource check in isolation.TestNewSyncerDiscovery to test config timeout isolation.<sub>🤖 Agent session</sub>
<!-- factory:task-output kind=Change task=recipe-care-comments-20261126-195830-0140 -->
🤖 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.
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 -->
🤖 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 -->
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).
🤖 AI Factory started addressing review feedback for this pull request.
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-4has failed in all three attempts, each time inTestStandbyKeepsLeaderResourceID:
…
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 -->
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 -->
Approved these changes.
[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:
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":[]} -->
acpana
lovelace-coder-bot
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
syncerGVKsWithServiceGeneratedIDsregardless 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:
SyncerIntegrationwith a 10-second timeout to query served kinds from the API server.syncerGVKsWithServiceGeneratedIDsso that KRMSyncer rules are generated only for kinds actually served by the cluster.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 -->