Fix kueue updates and improve reconciler - #63
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR optimizes the misc controller reconcile flow by retrieving the cluster’s CRD names once per ClusterPolicy reconcile and reusing the result, while also improving Kueue object reconciliation to update labels consistently and clean up stale queues.
Changes:
- Retrieve CRD name list once in
ClusterPolicyReconcilerand pass it intoMiscReconcilerto avoid repeated CRD listing. - Improve Kueue reconciliation by ensuring
ownerlabeling is applied/updated and by deleting stale ClusterQueues/LocalQueues when policy changes. - Add tests for stale Kueue queue cleanup and for using
APIReaderduring LocalQueue cleanup.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| internal/controller/misc_controller.go | Reworks CRD existence checks to use pre-fetched CRD names, adds Kueue stale-queue cleanup, and updates label handling + LocalQueue listing via APIReader. |
| internal/controller/clusterpolicy_controller.go | Fetches CRD names once per reconcile and passes them into sub-reconcilers; wires APIReader from manager. |
| internal/controller/misc_controller_test.go | Updates tests for new owner-label behavior and adds coverage for stale queue cleanup + APIReader usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0654908 to
d0a2d8c
Compare
When clusterpolicy was edited with different localqueues, controller left previous queues in the cluster. They should be removed. Signed-off-by: Tuomas Katila <tuomas.katila@intel.com>
Operator uses a cached client to list cluster objects. As LocalQueues were not requested to be cached, they couldn't be listed with the client. ClusterQueues are cluster-wide so they seem to be cache by default, so they were found correctly. Signed-off-by: Tuomas Katila <tuomas.katila@intel.com>
misc controller has conditional paths that depend on CRDs installed to the cluster. Misc controller queried CRDs a few times which resulted in misc controller being slow. The difference is a few seconds on my test bench. Signed-off-by: Tuomas Katila <tuomas.katila@intel.com>
Signed-off-by: Tuomas Katila <tuomas.katila@intel.com>
d0a2d8c to
46e1a99
Compare
| nn := types.NamespacedName{Name: lq.Name, Namespace: lq.Namespace} | ||
| if _, exists := expectedLocalQueues[nn]; exists { | ||
| klog.V(5).Infof("Local queue %s/%s found in policy, skip", lq.Namespace, lq.Name) | ||
|
|
There was a problem hiding this comment.
Here we also need to check that the local queue belongs to the intended cluster queue. If not, the local queue should be deleted and re-created with the intended cluster queue.
Retrieving CRDs seems to be slow and misc_controller was querying them many times. By retrieving them once, makes misc_controller reconciler much faster.