Repository navigation
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⛔ Files ignored due to path filters (1)
⚙️ Run configuration
⛔ Files ignored due to path filters (1)
You can disable this status message by setting the Use the checkbox below for a quick retry:
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughScaledObject target references can use an exact name, name prefix, or label selector. The criteria combine, and resolution requires exactly one workload. Admission, reconciliation, scaling, HPA construction, and finalization use the resolved workload name. ChangesScale target resolution
Estimated code review effort: 4 (Complex) | ~45 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant ScaledObject
participant AdmissionWebhook
participant ResolveScaleTargetName
participant KubernetesAPI
participant HPAController
ScaledObject->>AdmissionWebhook: submit target reference
AdmissionWebhook->>ResolveScaleTargetName: resolve reference and GVK
ResolveScaleTargetName->>KubernetesAPI: list matching target-kind objects
KubernetesAPI-->>ResolveScaleTargetName: matching objects
ResolveScaleTargetName-->>AdmissionWebhook: resolved workload name or error
AdmissionWebhook-->>ScaledObject: admission result
ScaledObject->>HPAController: reconcile admitted target
HPAController->>ResolveScaleTargetName: resolve target name
ResolveScaleTargetName-->>HPAController: resolved workload name
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Out of Scope Changes checkExplanation The target-resolution implementation and its tests support [ ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: kedacore/keda/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID: 4cf406b7-529b-442e-bdcd-c6fb6e0176ee
⛔ Files ignored due to path filters (1)
apis/keda/v1alpha1/zz_generated.deepcopy.gois excluded by!**/zz_generated*.go
📒 Files selected for processing (13)
apis/keda/v1alpha1/scaledobject_types.goapis/keda/v1alpha1/scaledobject_webhook.goapis/keda/v1alpha1/scaledobject_webhook_test.goconfig/crd/bases/keda.sh_scaledobjects.yamlcontrollers/keda/hpa.gocontrollers/keda/scaledobject_controller.gocontrollers/keda/scaledobject_finalizer.gopkg/fallback/fallback.gopkg/scaling/executor/scale_scaledobjects.gopkg/scaling/executor/scale_scaledobjects_test.gopkg/scaling/resolver/scale_resolvers.gopkg/scaling/resolver/scale_target.gopkg/scaling/resolver/scale_target_test.go
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
kedacore/keda-docs(manual) → reviewed against open PR#1888feat/selectors-nodes-docsinstead of the default branchkedacore/charts(manual) → reviewed against open PR#914feat/selectors-nodes-syncinstead of the default branch
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
46d73da to
24e18d5
Compare
|
All bot findings addressed in 24e18d5:
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Resolve selector-bearing neighboring targets during admission… · scaledobject_webhook.go:497-509
apis/keda/v1alpha1/scaledobject_webhook.go:497-509
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winResolve selector-bearing neighboring targets during admission conflict checks.
findConflictingScaledObjectresolves a neighbor only whenNameis empty. A neighbor withName=Nand a non-matchingNamePrefixorLabelSelectortherefore keeps rawNand can falsely conflict with an incoming target resolved toN. Resolve whenever either selector is present. Preserve the fixed-name fast path.Suggested fix
- if otherTargetName == "" { + if otherTargetName == "" || + so.Spec.ScaleTargetRef.NamePrefix != "" || + so.Spec.ScaleTargetRef.LabelSelector != nil {
🧹 Nitpick comments (1)
pkg/scaling/executor/scale_scaledobjects_test.go (1)
1421-1421: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse selector-based callers in both negative cases.
fixedRefreturns before conflict scanning. The distinct-target and unresolvable-neighbor tests therefore do not exercise their stated branches. Use a selector-based caller and fixture for the distinct-target case. In the unresolvable-neighbor case, remove the fixed target owner and call with a selector so the ghost neighbor is the only candidate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: kedacore/keda/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID: c17d3cc5-dc2f-4ff9-baad-211f44ec7bd3
⛔ Files ignored due to path filters (1)
apis/keda/v1alpha1/zz_generated.deepcopy.gois excluded by!**/zz_generated*.go
📒 Files selected for processing (6)
apis/keda/v1alpha1/scaledobject_types.goconfig/crd/bases/keda.sh_scaledobjects.yamlcontrollers/keda/scaledobject_controller.gocontrollers/keda/scaledobject_controller_test.gopkg/scaling/executor/scale_scaledobjects.gopkg/scaling/executor/scale_scaledobjects_test.go
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
kedacore/keda-docs(manual) → reviewed against open PR#1888feat/selectors-nodes-docsinstead of the default branchkedacore/charts(manual) → reviewed against open PR#914feat/selectors-nodes-syncinstead of the default branch
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
|
Reworked in d87d1d3, all bot findings from this round addressed:
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: kedacore/keda/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID: ab3b34a8-3c75-4977-8217-11c6bebb2fbe
⛔ Files ignored due to path filters (1)
apis/keda/v1alpha1/zz_generated.deepcopy.gois excluded by!**/zz_generated*.go
📒 Files selected for processing (10)
apis/keda/v1alpha1/scaledobject_webhook.goapis/keda/v1alpha1/scaledobject_webhook_test.gocontrollers/keda/scaledobject_controller.gocontrollers/keda/scaledobject_controller_test.gopkg/fallback/fallback.gopkg/scaling/executor/scale_scaledobjects.gopkg/scaling/resolver/scale_resolvers.gopkg/scaling/resolver/scale_resolvers_test.gopkg/scaling/resolver/scale_target.gopkg/scaling/resolver/scale_target_test.go
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
kedacore/keda-docs(manual) → reviewed against open PR#1888feat/selectors-nodes-docsinstead of the default branchkedacore/charts(manual) → reviewed against open PR#914feat/selectors-nodes-syncinstead of the default branch
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
Round 2 in 05e232b (single commit, force-pushed):
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: kedacore/keda/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID: 00f16a23-fa7e-4477-8248-db59f202d075
⛔ Files ignored due to path filters (1)
apis/keda/v1alpha1/zz_generated.deepcopy.gois excluded by!**/zz_generated*.go
📒 Files selected for processing (6)
apis/keda/v1alpha1/scaledobject_webhook.gocontrollers/keda/scaledobject_controller.gopkg/scaling/executor/scale_scaledobjects.gopkg/scaling/executor/scale_scaledobjects_test.gopkg/scaling/resolver/scale_resolvers.gopkg/scaling/resolver/scale_target_test.go
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
kedacore/keda-docs(manual) → reviewed against open PR#1888feat/selectors-nodes-docsinstead of the default branchkedacore/charts(manual) → reviewed against open PR#914feat/selectors-nodes-syncinstead of the default branch
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
|
Round 3 in 966fb20:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · This test passes for the wrong reason, and its expectation… · scaledobject_webhook_test.go:166-169
apis/keda/v1alpha1/scaledobject_webhook_test.go:166-169
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winThis test passes for the wrong reason, and its expectation contradicts the webhook logic.
fixedSouses a fixed name andselectorSouses a prefix. For this pair,incomingWinsDuplicateRacereturnstrue, sofindConflictingScaledObjectskips the neighbor. No HPA exists, soverifyHpasdoes not reject either. The firstCreatetherefore succeeds.
Eventuallythen retries. The retry fails withAlreadyExists, andShould(HaveOccurred())accepts that error. The test passes even though admission accepted the object.
TestIncomingWinsDuplicateRace(Line 2361) states the opposite rule: "fixed incoming must beat selector other regardless of age." Fix it in one of two ways:
- Expect the create to succeed. This matches the documented rule that fixed names take precedence.
- Change the webhook to reject this case.
In both cases, assert the exact error text so that an
AlreadyExistserror cannot satisfy the assertion.💚 Proposed fix (keep fixed-name precedence)
- fixedSo := createScaledObject("so-fixed", namespaceName, "ingress-sensor-abc12", "apps/v1", "Deployment", false, map[string]string{}, "") - Eventually(func() error { - return k8sClient.Create(context.Background(), fixedSo) - }).Should(HaveOccurred()) + fixedSo := createScaledObject("so-fixed", namespaceName, "ingress-sensor-abc12", "apps/v1", "Deployment", false, map[string]string{}, "") + // Fixed-name refs win the runtime tie-break over selector refs. + Eventually(func() error { + return k8sClient.Create(context.Background(), fixedSo) + }).ShouldNot(HaveOccurred())
🧹 Nitpick comments (1)
apis/keda/v1alpha1/scaledobject_webhook.go (1)
520-550: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoffReuse workload listings during duplicate admission checks.
Each selector-based neighbor calls
resolveScaleTargetName. The function performs a namespace-scoped LIST of the neighbor's workload GVK throughunstructured.UnstructuredList. Controller-runtime v0.24.1 does not cache unstructured client reads by default, so these LISTs can reach the API server separately. Many selector-based ScaledObjects can increase admission latency and may approach the webhook timeout.List each GVK once per
findConflictingScaledObjectcall. Apply each neighbor's label selector,Name, andNamePrefixfilters in memory. Preserve the direct-client fallback for an empty cached result.♻️ Suggested fix
+ listed := map[schema.GroupVersionKind][]unstructured.Unstructured{} for i := range candidates { ... - resolved, err := resolveScaleTargetName(ctx, kc, so.Namespace, soGckr.GroupVersionKind(), so.Spec.ScaleTargetRef) + // Fetch the namespace list for this GVK once, store it in + // listed, and match LabelSelector, Name, and NamePrefix + // against the stored items in memory. + resolved, err := resolveScaleTargetNameFrom(listed, ctx, kc, so.Namespace, soGckr.GroupVersionKind(), so.Spec.ScaleTargetRef)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: kedacore/keda/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID: 4dbb9525-1832-4246-b4a9-d19567c2c815
⛔ Files ignored due to path filters (1)
apis/keda/v1alpha1/zz_generated.deepcopy.gois excluded by!**/zz_generated*.go
📒 Files selected for processing (2)
apis/keda/v1alpha1/scaledobject_webhook.goapis/keda/v1alpha1/scaledobject_webhook_test.go
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
kedacore/keda-docs(manual) → reviewed against open PR#1888feat/selectors-nodes-docsinstead of the default branchkedacore/charts(manual) → reviewed against open PR#914feat/selectors-nodes-syncinstead of the default branch
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
|
Round 4 in b54fcf4:
|
|
@coderabbitai review |
|
Signed-off-by: Said Sakuh <said.sakuh@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: kedacore/keda/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID: 2aa0feb3-bab9-409f-8f79-3118858d50b0
⛔ Files ignored due to path filters (1)
apis/keda/v1alpha1/zz_generated.deepcopy.gois excluded by!**/zz_generated*.go
📒 Files selected for processing (4)
apis/keda/v1alpha1/scaledobject_webhook.goapis/keda/v1alpha1/scaledobject_webhook_test.gopkg/scaling/resolver/scale_target.gopkg/scaling/resolver/scale_target_test.go
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
kedacore/keda-docs(manual) → reviewed against open PR#1888feat/selectors-nodes-docsinstead of the default branchkedacore/charts(manual) → reviewed against open PR#914feat/selectors-nodes-syncinstead of the default branch
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
|
Note on the informer-cache thread (resolved): the typed-list optimization for selector resolution lives in #8234 single commit, which is a superset of this PR. This PR is intentionally untouched so its running checks are not invalidated for a Minor perf item; the behavior here is correct, uncached reads only. Happy to cherry-pick it here too if preferred. |
|
@coderabbitai review |

Controllers that name objects dynamically (Argo Events sensors,
GenerateNameDeployments) cannot be referenced by a fixedscaleTargetRef.name. This change adds optionalnamePrefixandlabelSelectorfields. All clauses combine with AND and must resolve to exactly one object per reconcile.What changed:
namePrefix,labelSelector,status.resolvedTargetName.nameis now optional when selectors are given.pkg/scaling/resolver/scale_target.go): fixed name passes through with no listing; otherwise prefix and labels filter one list call; zero matches hold, several matches fail closed with typed errors.Testing: new unit tests for the resolver, 6 new webhook envtest specs (including a mutation check: they fail without the fix), full
controllersenvtest suite green.Checklist
make generate-scalers-schemahas been run to update any outdated generated files — N/A (no scaler metadata changed)Fixes #8231
Relates to #4188, #5717, #5707
Relates to kedacore/keda-docs#1888, kedacore/charts#914