Skip to content

feat(helm): add switch for admission webhook namespaceSelector - #2091

Merged
hami-robot[bot] merged 2 commits into
Project-HAMi:masterfrom
spencercjh:feat/chart-switch-for-admission-webhook
Jul 21, 2026
Merged

feat(helm): add switch for admission webhook namespaceSelector#2091
hami-robot[bot] merged 2 commits into
Project-HAMi:masterfrom
spencercjh:feat/chart-switch-for-admission-webhook

Conversation

@spencercjh

@spencercjh spencercjh commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Most of this Pull Request was generated or revised with the assistance of AI tools(kimi cli with K3 max). I have reviewed the resulting content and take full responsibility for its accuracy, security, licensing compliance, and inclusion in this project.

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds an explicit chart option scheduler.admissionWebhook.manageNamespaceSelector (default true) to control whether the chart renders and manages the webhook namespaceSelector field:

  • true (default): keep current behavior and render namespaceSelector exactly as today
  • false: do not render namespaceSelector, so the field can be fully managed by the platform / external controller

On managed platforms such as AKS, the control plane mutates MutatingWebhookConfiguration and takes ownership of namespaceSelector via admissionsenforcer (Azure/AKS#4002). Since the chart currently always renders that field, Helm fights the platform for field ownership and subsequent helm upgrade / helmfile sync may fail with a server-side apply conflict. Setting this option to false lets those environments opt out.

Which issue(s) this PR fixes:
Fixes #2039

Special notes for your reviewer:

This change is about field ownership compatibility only; it does not change HAMi webhook semantics by default.

  • Default rendering verified byte-identical to master (helm template diff against master is empty).
  • With scheduler.admissionWebhook.manageNamespaceSelector=false, the entire namespaceSelector: block is omitted while objectSelector and all other webhook fields render unchanged.
  • helm lint and the trivy config chart check (CI lint_chart equivalent) both pass.

Does this PR introduce a user-facing change?:

Yes. It introduces an optional chart value for managed Kubernetes environments where the webhook namespaceSelector is mutated / owned externally. Default behavior remains unchanged.

Summary by CodeRabbit

  • New Features

    • Added a Helm configuration option to control whether the scheduler admission webhook manages its namespace selector.
    • The option defaults to enabled; setting it to disabled will omit the namespace selector from the webhook configuration.
  • Documentation

    • Updated the chart values documentation to describe the new scheduler.admissionWebhook.manageNamespaceSelector setting and its default value.

Add scheduler.admissionWebhook.manageNamespaceSelector (default true)
to let the chart opt out of rendering and managing the webhook
namespaceSelector field.

On managed platforms such as AKS, the control plane mutates and owns
namespaceSelector via admissionsenforcer, which conflicts with Helm
server-side apply field ownership and breaks helm upgrade. Setting the
value to false leaves the field fully managed by the platform while
default behavior remains unchanged.

Refs Project-HAMi#2039

Signed-off-by: spencercjh <jiahao.cai@dynamia.ai>
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c16dcea5-363d-4f42-8274-9fef1301ecc4

📥 Commits

Reviewing files that changed from the base of the PR and between 7e393a3 and f4ec476.

📒 Files selected for processing (1)
  • charts/hami/templates/scheduler/webhook.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • charts/hami/templates/scheduler/webhook.yaml

📝 Walkthrough

Walkthrough

The HAMi Helm chart adds scheduler.admissionWebhook.manageNamespaceSelector, defaults it to true, documents it, and conditionally renders the scheduler webhook’s namespaceSelector block based on its value.

Changes

Admission webhook selector management

Layer / File(s) Summary
Namespace selector management toggle
charts/hami/values.yaml, charts/hami/templates/scheduler/webhook.yaml, charts/hami/README.md
Adds the manageNamespaceSelector value, gates namespaceSelector rendering on it, and documents its default.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: chaunceyjiang, archlitchi, fouof, dsfans2014

Poem

A rabbit hops through Helm’s bright chart,
A selector toggle does its part.
True keeps the old path in sight,
False lets platforms steer it right.
“No ownership hops!” the bunny sings.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main Helm change: adding a switch for admission webhook namespaceSelector management.
Linked Issues check ✅ Passed The PR adds manageNamespaceSelector, defaults it to true, and omits namespaceSelector when false, matching #2039.
Out of Scope Changes check ✅ Passed The changes stay within the chart option, template gating, and documentation needed for the requested escape hatch.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
charts/hami/templates/scheduler/webhook.yaml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested review from FouoF and archlitchi July 20, 2026 14:07

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a new Helm chart configuration option, manageNamespaceSelector, which allows users to toggle the rendering of the webhook's namespaceSelector field to prevent ownership conflicts on managed Kubernetes platforms like AKS. The review feedback points out a potential breaking change during upgrades: if an existing user upgrades without this new key in their custom values, it will evaluate to falsy and omit the namespace selector. The reviewer suggests a safer conditional check using hasKey to ensure it defaults to true when the key is absent.

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 charts/hami/templates/scheduler/webhook.yaml Outdated
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 61.13% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@spencercjh

Copy link
Copy Markdown
Contributor Author

/assign mesutoezdil

@wawa0210

Copy link
Copy Markdown
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


/assign mesutoezdil

With helm upgrade --reuse-values, the previous release's computed
values are reused without merging the new chart's values.yaml, so
scheduler.admissionWebhook.manageNamespaceSelector resolves to nil
and the namespaceSelector block would be silently dropped.

Guard with hasKey so the block renders unless the value is explicitly
set to false.

Refs Project-HAMi#2039

Signed-off-by: spencercjh <jiahao.cai@dynamia.ai>
@mesutoezdil

Copy link
Copy Markdown
Contributor

/lgtm

@archlitchi archlitchi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@hami-robot

hami-robot Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: archlitchi, spencercjh

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

The pull request process is described 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

@hami-robot hami-robot Bot added the approved label Jul 21, 2026
@hami-robot
hami-robot Bot merged commit 0317d82 into Project-HAMi:master Jul 21, 2026
17 checks passed
@spencercjh
spencercjh deleted the feat/chart-switch-for-admission-webhook branch July 21, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] add an escape hatch to stop managing admission webhook namespaceSelector on AKS-like platforms

4 participants