perf(webhook): use GetQueuesByParent to get child queues#5506
perf(webhook): use GetQueuesByParent to get child queues#5506DSFans2014 wants to merge 1 commit into
GetQueuesByParent to get child queues#5506Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
GetQueuesByParent to get childQueuesGetQueuesByParent to get child queues
There was a problem hiding this comment.
Code Review
This pull request refactors queue retrieval logic by replacing manual filtering with config.GetQueuesByParent and optimizes task name tracking in job validation using an empty struct map. However, deleting the listQueueChild helper function will cause compilation errors as it is still referenced elsewhere in the codebase; it should instead be refactored to wrap the new parent-based lookup. Additionally, the variable childQueueNames should be renamed to childQueues to accurately reflect its new type ([]*Queue instead of []string).
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR aims to improve webhook validation performance by using the indexed AdmissionServiceConfig.GetQueuesByParent helper (instead of listing all queues and filtering) when checking hierarchical queue relationships during admission.
Changes:
- Switch queue hierarchy validation to use
config.GetQueuesByParentfor child-queue lookups. - Simplify duplicate task-name tracking in job validation by using a
map[string]struct{}set. - Minor error-message wording fix (whitespace) in CPU request validation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/webhooks/admission/queues/validate/validate_queue.go | Replaces a list-and-filter child-queue lookup with GetQueuesByParent and removes the old helper. |
| pkg/webhooks/admission/jobs/validate/admit_job.go | Uses GetQueuesByParent to detect non-leaf queues and refactors task-name dedupe set. |
Comments suppressed due to low confidence (2)
pkg/webhooks/admission/queues/validate/validate_queue.go:397
listQueueChildwas removed in this change, but the file still calls it (e.g., invalidateQueueDeletingandfindSubtreeMaxCapability). This will fail to compile unless those call sites are updated (preferably toconfig.GetQueuesByParent) or a compatibility helper is kept.
childQueueNames, err := config.GetQueuesByParent(parentQueue.Name)
if err != nil {
return fmt.Errorf("failed to list child queues of queue %s: %v", parentQueue.Name, err)
}
pkg/webhooks/admission/queues/validate/validate_queue.go:397
config.GetQueuesByParentreturns[]*Queue, so the variable namechildQueueNamesis now misleading. Renaming it tochildQueues(or similar) will make the code clearer.
childQueueNames, err := config.GetQueuesByParent(parentQueue.Name)
if err != nil {
return fmt.Errorf("failed to list child queues of queue %s: %v", parentQueue.Name, err)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e81c9e7 to
a8ec79c
Compare
a8ec79c to
a7eedc5
Compare
Signed-off-by: james <open4pd@4paradigm.com>
a7eedc5 to
ee7f047
Compare
What type of PR is this?
What this PR does / why we need it:
If informer is available,
GetQueuesByParentuse the efficient index-based lookup. Prefer usingGetQueuesByParentto obtain the child queue.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?