Skip to content

fix(keda): allow webhook to get HPAs - #938

Open
avneetbansal-aws wants to merge 1 commit into
kedacore:mainfrom
avneetbansal-aws:fix/webhook-clusterrole-hpa-get
Open

avneetbansal-aws wants to merge 1 commit into
kedacore:mainfrom
avneetbansal-aws:fix/webhook-clusterrole-hpa-get

Conversation

@avneetbansal-aws

@avneetbansal-aws avneetbansal-aws commented Nov 21, 2026 •

Copy link
Copy Markdown

The webhook ClusterRole grants only list and watch on horizontalpodautoscalers. When the ScaledObject admission webhook looks up an HPA and the informer cache has not yet seen it, the webhook falls back to a direct API read, which needs the get verb. Without it, that fallback is denied with a forbidden error and the ScaledObject admission can fail. This change adds get to the horizontalpodautoscalers rule in keda/templates/webhooks/clusterrole.yaml. Nothing else is modified and the chart version is not bumped, since individual PRs do not need to do that.

Fixes kedacore/keda#8386

Treating a cache NotFound as final inside the webhook is an alternative fix on the KEDA side. Maintainers may prefer that approach, and this RBAC change can be closed if so.

I could not run helm template locally because helm is not installed in my environment, so the change was checked by reading the diff only. It is a one-line addition to an existing verbs list.

Checklist

  • I have verified that my change is according to the deprecations and breaking changes policy
  • Commits are signed with Developer Certificate of Origin (DCO)
  • README is updated with new configuration values (not applicable, no new values)
  • A PR is opened to update KEDA core (not applicable, only the chart RBAC changes)

The webhook ClusterRole grants only list and watch on autoscaling horizontalpodautoscalers. With cache-miss-to-direct-client enabled, getFromCacheOrDirect falls back to a direct Get when the cached read is NotFound, which is always the case for a new ScaledObject, so the request is denied as forbidden. Add the get verb.

Fixes kedacore/keda#8386

Tests: helm template was not run (helm is not installed in this environment). Change is one added verb in a ClusterRole template, checked by git diff only. No chart version bump, per CONTRIBUTING.md.
Signed-off-by: avneetbansal-aws <284363899+avneetbansal-aws@users.noreply.github.com>
@avneetbansal-aws
avneetbansal-aws requested review from a team as code owners November 21, 2026 20:47
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The webhook ClusterRole now grants get, alongside list and watch, for horizontal pod autoscalers.

Changes: Webhook HPA permissions

Layer / File(s) Summary
HPA read access
keda/templates/webhooks/clusterrole.yaml
The webhook ClusterRole adds the get verb for horizontal pod autoscalers.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: wozniakjan, jorturfer

Merge Risk: Minimal · up to fad40

This change lets the ScaledObject admission webhook read an HPA directly when it is missing from the cache. That restores admission of new ScaledObjects when cache-miss-to-direct-client is enabled. The added permission is read-only and limited to HPAs, so the risk of merging is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(keda): allow webhook to get HPAs" matches the changeset, which adds the get verb for horizontalpodautoscalers to the webhook ClusterRole. It names the main change and the purpose. It us…
Linked Issues check Passed [#8386] The issue requires that a ScaledObject whose HPA does not yet exist is admitted when cache-miss-to-direct-client is "true". The root cause is that the webhook ClusterRole grants only list and …
Out of Scope Changes check Passed The whole-PR diff against the merge base changes one file and adds one line, '- get', to the existing horizontalpodautoscalers verbs list. The change directly implements the requirement in #8386. The …
Description check Passed The description states that the webhook ClusterRole grants only list and watch on horizontalpodautoscalers, and that adding the get verb to the horizontalpodautoscalers rule in keda/templates/webhooks…
Full details: Title check

Explanation

The title "fix(keda): allow webhook to get HPAs" matches the changeset, which adds the get verb for horizontalpodautoscalers to the webhook ClusterRole. It names the main change and the purpose. It uses a conventional commit prefix, which is acceptable.

Full details: Linked Issues check

Explanation

[#8386] The issue requires that a ScaledObject whose HPA does not yet exist is admitted when cache-miss-to-direct-client is "true". The root cause is that the webhook ClusterRole grants only list and watch on autoscaling/horizontalpodautoscalers, so the direct-client fallback is forbidden. The reviewed diff adds get to that verbs list in keda/templates/webhooks/clusterrole.yaml. This matches the issue's first suggested fix. The issue also allows a KEDA-side alternative, which this PR does not implement. That alternative is optional, so its absence does not fail this check. No automated test exists for this RBAC rule in the diff. The issue does not require one. Helm rendering was not run by the author, but that is a verification step, not a requirement.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes one file and adds one line, '- get', to the existing horizontalpodautoscalers verbs list. The change directly implements the requirement in #8386. The chart version and other files are unchanged, as the PR description states. No unrelated change is present.

Full details: Description check

Explanation

The description states that the webhook ClusterRole grants only list and watch on horizontalpodautoscalers, and that adding the get verb to the horizontalpodautoscalers rule in keda/templates/webhooks/clusterrole.yaml fixes a forbidden error on ScaledObject admission. This matches the raw summary, which says the ClusterRole now grants get in addition to list and watch. The description also names the linked issue and explains the alternative KEDA-side fix, so it is specific and on topic.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e600314 and fad40d7.

Files selected for processing: 1

  • keda/templates/webhooks/clusterrole.yaml
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2.21.1: ScaledObject webhook denies every create with cache-miss-to-direct-client, webhook ClusterRole lacks get on HPAs

1 participant