fix: apply fallback in polling loop to enable scaling from zero#7244
fix: apply fallback in polling loop to enable scaling from zero#7244zroubalik merged 12 commits intokedacore:mainfrom
Conversation
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
|
Thank you for your contribution! 🙏 Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected. While you are waiting, make sure to:
Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient. Learn more about our contribution guide. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
/run-e2e internals |
|
/run-e2e internals |
|
/run-e2e internals |
9a0f243 to
05a3da5
Compare
|
/run-e2e internals |
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
|
/run-e2e internals |
There was a problem hiding this comment.
Pull request overview
This PR addresses a critical bug where ScaledObjects remained at zero replicas indefinitely when scalers encountered errors, because fallback was only triggered during HPA metric requests but not during the polling loop. The fix ensures fallback works consistently in both paths, enabling proper scaling from zero even when errors occur.
- Introduced
processMetricsWithFallbackhelper function to consolidate fallback logic across HPA requests and polling interval checks - Extended
scalerStatestruct to track fallback activation state and fallback metrics - Modified
getScalerStateto treat fallback-active scalers as active, enabling scale-up from zero replicas - Added comprehensive test coverage for scaling from zero with fallback
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/scaling/scale_handler.go | Adds processMetricsWithFallback helper function and integrates fallback logic into both GetScaledObjectMetrics (HPA path) and getScalerState (polling path); moves scalerState struct definition earlier and extends it with fallback fields; ensures fallback-active scalers are considered active to enable scaling from zero |
| tests/internals/fallback/fallback.go | Adds TestFallbackFromZero test case to verify that fallback correctly triggers and scales from 0 to fallback replica count when metrics server is unavailable; integrates new test into main test suite |
| CHANGELOG.md | Documents the fix for applying fallback in polling loop to enable scaling from zero, referencing issue #7239 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
|
/run-e2e internals |
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
|
/run-e2e internals |
|
/run-e2e internals |
|
/run-e2e internals |
|
/run-e2e internals |
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
|
/run-e2e internals |
zroubalik
left a comment
There was a problem hiding this comment.
Great, thanks for fixing this!
I have just a small nit wrt styling
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
e8e46b4 to
40c12a4
Compare
|
/run-e2e fallback |
…core#7244) Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com> Signed-off-by: Dmitriy Altuhov <altuhovd@gmail.com>
…core#7244) Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
…core#7244) Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
When a ScaledObject is scaled to zero and the scaler encounters an error, the fallback mechanism is only triggered during HPA metric requests via
GetScaledObjectMetrics, but not during the polling loop ingetScaledObjectState. This caused the ScaledObject to remain at zero replicas indefinitely when errors occurred, as the polling loop would continuously fail without activating the fallback, preventing HPA from ever being consulted.Fallback now works in both, HPA requests and polling interval checks.
The only question I have is whether it's by design that it doesn't switch to Fallback with 0 replicas, but I can't think of that myself. Please consider this when considering whether this was a deliberate choice. If not, I believe this PR resolves the issue.
Some extra new info;
It turned out to be a more change than I anticipated. I initially thought I'd add a simple fallback to
getScalerState, but it turned out that scalingModifiers started having issues.Therefore, I had to make some further adjustments to ensure the fallback worked properly from all positions.
Checklist
Fixes #7239