Skip to content

perf(webhook): use GetQueuesByParent to get child queues#5506

Open
DSFans2014 wants to merge 1 commit into
volcano-sh:masterfrom
DSFans2014:refact/webhook
Open

perf(webhook): use GetQueuesByParent to get child queues#5506
DSFans2014 wants to merge 1 commit into
volcano-sh:masterfrom
DSFans2014:refact/webhook

Conversation

@DSFans2014

Copy link
Copy Markdown
Contributor

What type of PR is this?

What this PR does / why we need it:

If informer is available, GetQueuesByParent use the efficient index-based lookup. Prefer using GetQueuesByParent to obtain the child queue.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?


Copilot AI review requested due to automatic review settings June 25, 2026 08:19
@volcano-sh-bot volcano-sh-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 25, 2026
@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign monokaix for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@DSFans2014 DSFans2014 changed the title perf(webhook): use GetQueuesByParent to get childQueues perf(webhook): use GetQueuesByParent to get child queues Jun 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pkg/webhooks/admission/queues/validate/validate_queue.go
Comment thread pkg/webhooks/admission/queues/validate/validate_queue.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.GetQueuesByParent for 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

  • listQueueChild was removed in this change, but the file still calls it (e.g., in validateQueueDeleting and findSubtreeMaxCapability). This will fail to compile unless those call sites are updated (preferably to config.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.GetQueuesByParent returns []*Queue, so the variable name childQueueNames is now misleading. Renaming it to childQueues (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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Signed-off-by: james <open4pd@4paradigm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants