Skip to content

Conversation

@suyiiyii
Copy link
Contributor

@suyiiyii suyiiyii commented Sep 2, 2025

What type of PR is this?

Bugfix

What this PR does / why we need it:

This PR adds permissions for managing namespaces (get, list, watch) in the admission webhook's ClusterRole. This is required for the mutating webhook to read namespace annotations and mutate PodGroup resources accordingly. Without these permissions, the webhook cannot access namespace annotations and will fail to update the PodGroup's queue field based on the namespace's settings.

Which issue(s) this PR fixes:

Fixes #4589

Special notes for your reviewer:

  • Verified that after adding the permissions, PodGroup mutation works as expected when namespace annotations are present.
  • Please review the permission scope for security and correctness.

Does this PR introduce a user-facing change?

NONE

The Volcano admission webhook can now mutate PodGroup resources based on namespace annotations, as the required permissions to read namespaces are granted.

Copilot AI review requested due to automatic review settings September 2, 2025 13:58
@volcano-sh-bot
Copy link
Contributor

Welcome @suyiiyii!

It looks like this is your first PR to volcano-sh/volcano.

Thank you, and welcome to Volcano. 😃

Copy link

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

Choose a reason for hiding this comment

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

Summary of Changes

Hello @suyiiyii, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a bug preventing the Volcano admission webhook from properly mutating PodGroup resources. It grants the necessary permissions for the webhook to access namespace annotations, ensuring that PodGroup objects can be correctly updated based on namespace-specific configurations.

Highlights

  • Admission Webhook Permissions: Adds "get", "list", "watch" permissions for "namespaces" to the Volcano admission webhook's ClusterRole, enabling it to read namespace annotations for PodGroup mutation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@volcano-sh-bot volcano-sh-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 2, 2025
Copy link

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

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 correctly adds the necessary RBAC permissions for the admission webhook to read namespace information, which is required for mutating PodGroups based on namespace annotations. The change is well-justified. I have one high-severity feedback item concerning the Helm chart configuration to ensure the new functionality is enabled by default for users.

Comment on lines +66 to +69
- apiGroups: [""]
resources: ["namespaces"]
verbs: ["get", "list", "watch"]

Choose a reason for hiding this comment

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

high

While these permissions are necessary for the podgroups/mutate webhook as described, this webhook is not enabled by default in the Helm chart's values.yaml. For the feature to work as intended with a default installation, /podgroups/mutate should be added to the enabled_admissions list in installer/helm/chart/volcano/values.yaml.

Without this change, users will have to manually discover and edit their values to enable the webhook, which could lead to confusion.

Copy link
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 namespace read permissions to the Volcano admission webhook's ClusterRole to enable PodGroup mutation based on namespace annotations.

  • Adds get, list, and watch permissions for namespaces in the admission webhook's ClusterRole
  • Enables the mutating webhook to read namespace annotations for PodGroup queue field updates
  • Fixes webhook failures when attempting to access namespace settings

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@suyiiyii
Copy link
Contributor Author

suyiiyii commented Sep 2, 2025

/assign @hwdef

- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.volcano.sh"]
resources: ["podgroups"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
Copy link
Member

Choose a reason for hiding this comment

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

We should add a check {{- if .Values.custom.enabled_admissions | regexMatch "/podgroups/mutate" }}, only add the rbac role when podgroup mutating webhook is configured.

@Monokaix
Copy link
Member

Monokaix commented Sep 3, 2025

/kind bug

@volcano-sh-bot volcano-sh-bot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 3, 2025
@Monokaix
Copy link
Member

Monokaix commented Sep 3, 2025

/ok-to-test
Thanks!

@volcano-sh-bot volcano-sh-bot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Sep 3, 2025
@Monokaix
Copy link
Member

Monokaix commented Sep 3, 2025

/approve

@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Monokaix

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 3, 2025
@kingeasternsun
Copy link
Contributor

kingeasternsun commented Sep 3, 2025

/lgtm
thanks.

@Monokaix
Copy link
Member

Monokaix commented Sep 3, 2025

/lgtm

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 3, 2025
@Monokaix
Copy link
Member

Monokaix commented Sep 3, 2025

Please also cherrypick to release 1.12, 1.11 and 1.10.

@volcano-sh-bot volcano-sh-bot merged commit a310085 into volcano-sh:master Sep 3, 2025
21 checks passed
@suyiiyii
Copy link
Contributor Author

suyiiyii commented Sep 3, 2025

Please also cherrypick to release 1.12, 1.11 and 1.10.

Thanks for merging my PR. Just to confirm, would you like me to cherrypick this PR to the release-1.12, release-1.11, and release-1.10 branches?
If so, I can work on it and open the corresponding pull requests.

@Monokaix
Copy link
Member

Monokaix commented Sep 3, 2025

Please also cherrypick to release 1.12, 1.11 and 1.10.

Thanks for merging my PR. Just to confirm, would you like me to cherrypick this PR to the release-1.12, release-1.11, and release-1.10 branches? If so, I can work on it and open the corresponding pull requests.

Yeah you can work on that: )

@suyiiyii suyiiyii deleted the fix/ns_read branch September 3, 2025 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PodGroup mutating webhook does not work due to missing namespace read permission

5 participants