-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: apply fallback in polling loop to enable scaling from zero #7244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Rick Brouwer <[email protected]>
|
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 |
Signed-off-by: Rick Brouwer <[email protected]>
9a0f243 to
05a3da5
Compare
|
/run-e2e internals |
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <[email protected]>
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <[email protected]>
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <[email protected]>
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <[email protected]>
|
/run-e2e internals |
There was a problem hiding this 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 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 <[email protected]> Signed-off-by: Rick Brouwer <[email protected]>
|
/run-e2e internals |
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <[email protected]>
|
/run-e2e internals |
|
/run-e2e internals |
|
/run-e2e internals |
|
/run-e2e internals |
|
/run-e2e internals |
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <[email protected]>
|
/run-e2e internals |
Signed-off-by: Rick Brouwer <[email protected]>
|
/run-e2e internals |
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