Skip to content

bundle controller shard filtering based on cluster changes#4567

Closed
johnjcool wants to merge 2 commits into
rancher:mainfrom
johnjcool:master
Closed

bundle controller shard filtering based on cluster changes#4567
johnjcool wants to merge 2 commits into
rancher:mainfrom
johnjcool:master

Conversation

@johnjcool
Copy link
Copy Markdown
Contributor

Refers to #4484

This PR updates shard filtering behavior for cluster->bundle fan-out in internal/cmd/controller/reconciler/bundle_controller.go. When a fleet.Cluster changes (labels/annotations/spec/status), the controller now only enqueues reconcile requests for fleet.Bundle objects that should be processed by the current shard (ShardID), preventing cross-shard reconciles triggered by cluster updates.

… changes

Ensure cluster-triggered bundle reconciles respect shard filtering in `internal/cmd/controller/reconciler/bundle_controller.go`.

Fixes rancher#4484

Signed-off-by: johnjcool <john.j.cool@googlemail.com>
@johnjcool johnjcool requested a review from a team as a code owner January 26, 2026 22:23
Copilot AI review requested due to automatic review settings January 26, 2026 22:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 adds shard filtering to prevent cross-shard reconciliations in the bundle controller. When cluster objects change, the controller now only enqueues bundles that belong to the current shard, improving efficiency in multi-shard deployments.

Changes:

  • Added shard filtering predicates to all watch handlers (Bundle, BundleDeployment, Cluster, Secret, ConfigMap)
  • Removed global WithEventFilter in favor of per-watch filtering
  • Ensured fan-out operations respect shard boundaries

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/cmd/controller/reconciler/bundle_controller.go Outdated
Signed-off-by: johnjcool <john.j.cool@googlemail.com>
@kkaempf kkaempf added this to the v2.14.0 milestone Jan 27, 2026
@kkaempf kkaempf added this to Fleet Jan 28, 2026
@weyfonk weyfonk moved this to 👀 In review in Fleet Jan 30, 2026
@weyfonk weyfonk modified the milestones: v2.14.0, v2.14.1 Feb 18, 2026
@weyfonk
Copy link
Copy Markdown
Contributor

weyfonk commented Feb 19, 2026

Thanks @johnjcool for your contribution :)
We like the idea, and need to figure out how far we want to take this.
For instance, recently-added monitoring of user-created secrets and config maps should also be impacted by this, yet we may not want to require users to add fleet.cattle.io/shard-ref labels to such resources.

@weyfonk
Copy link
Copy Markdown
Contributor

weyfonk commented Mar 2, 2026

Thanks @johnjcool for your contribution :) We like the idea, and need to figure out how far we want to take this. For instance, recently-added monitoring of user-created secrets and config maps should also be impacted by this, yet we may not want to require users to add fleet.cattle.io/shard-ref labels to such resources.

We've had a closer look, leading to the following conclusions:

  • Sharding predicates (sharding.FilterByShardID(r.ShardID)) are not necessary against monitored secrets and config maps, because the logic mapping config maps and secrets to bundles monitoring them already takes care of filtering out bundles living in different shards
  • Schedules were also affected by this mismatch; see Refine conditions for reconciles from cluster updates across shards #4730 for more details (@johnjcool , feel free to take a look, your comments are most welcome there too).

@weyfonk
Copy link
Copy Markdown
Contributor

weyfonk commented Mar 13, 2026

Superseded by #4730.
Thanks for this initiative :)

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

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants