Skip to content
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

Add Fallback option behavior for dynamic fallback calculation #6464

Merged
merged 20 commits into from
Feb 22, 2025

Conversation

rickbrouwer
Copy link
Contributor

@rickbrouwer rickbrouwer commented Jan 5, 2025

When you are running a large number of pods and something goes wrong, Keda uses a fallback (if configured). However, the difference between the fallback.replicas and the current number of replicas can be large.
"Something going wrong" can also be temporary, which means it can suddenly scale down considerably and then return to the correct number of replicas.

With this PR, I want to make a new option behavior for dynamic fallback calculation.

You can indicate that it should use the current number of replicas (CurrentReplicasIfHigher ) as fallback if current replicas is higher. If the given fallback.replicas is higher than the current replicas, then the fallback.replicas will be used.
Also you can indicate that it should use the current number of replicas (CurrentReplicasIfLower ) as fallback if current replicas is lower. If the given fallback.replicas is higher than the current replicas, then the current replicas will be used.

  • A new parameter has been added to the fallback struct (behavior) with three options Static (default), CurrentReplicasIfHigher and CurrentReplicasIfLower.
  • An adjustment has been made in the fallback.go to retrieve the current number of replicas
  • In the scale_scaledobjects.go there was code that determined what the current number of replicas was. This has been moved to the scale_resolvers.go
  • Fallback modified to determine whether to fall back to the fallback.replicas or the current number of replicas

If for any reason this option is not desired, please let me know.

Checklist

Fixes #6450
Docs: kedacore/keda-docs#1519
Relates to discussion: #6334

@rickbrouwer rickbrouwer requested a review from a team as a code owner January 5, 2025 17:50
@rickbrouwer rickbrouwer marked this pull request as draft January 5, 2025 17:50
Signed-off-by: Rick Brouwer <[email protected]>
Signed-off-by: Rick Brouwer <[email protected]>
Signed-off-by: Rick Brouwer <[email protected]>
Copy link
Member

@wozniakjan wozniakjan left a comment

Choose a reason for hiding this comment

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

lgtm, I like this a lot!

@rickbrouwer rickbrouwer marked this pull request as draft January 15, 2025 16:31
@rickbrouwer rickbrouwer force-pushed the fallback branch 3 times, most recently from caa059c to 34abee5 Compare January 15, 2025 18:03
@rickbrouwer rickbrouwer marked this pull request as ready for review January 15, 2025 18:04
@rickbrouwer rickbrouwer changed the title Use CurrentReplicas as a minimum for fallback replicas Add Fallback option UseCurrentReplicasAsMinimum Jan 16, 2025
Signed-off-by: rickbrouwer <[email protected]>
Copy link
Member

@wozniakjan wozniakjan left a comment

Choose a reason for hiding this comment

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

a minor suggestion for simplification, I think semantically this should be equivalent, just less code to maintain :)

Let me know if you find any discrepancies

rickbrouwer and others added 3 commits January 17, 2025 15:47
Co-authored-by: Jan Wozniak <[email protected]>
Signed-off-by: rickbrouwer <[email protected]>
Co-authored-by: Jan Wozniak <[email protected]>
Signed-off-by: rickbrouwer <[email protected]>
Signed-off-by: Rick Brouwer <[email protected]>
@JorTurFer
Copy link
Member

Sorry because I'm late, I've posted a comment in the issue about the approach, PTAL and share your thoughts

Signed-off-by: Rick Brouwer <[email protected]>
Copy link
Member

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

Great stuff!

Shouldn't we also add currentReplicas mode to always fallback to current replicas no matter if the count is lower or higher?

@rickbrouwer rickbrouwer force-pushed the fallback branch 3 times, most recently from fe1d3a0 to 76d35eb Compare February 6, 2025 14:43
Signed-off-by: Rick Brouwer <[email protected]>
Copy link
Member

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

I think that we should also think about e2e test for this feature

Signed-off-by: rickbrouwer <[email protected]>
@rickbrouwer
Copy link
Contributor Author

I think that we should also think about e2e test for this feature

added an e2e test

@wozniakjan
Copy link
Member

wozniakjan commented Feb 20, 2025

/run-e2e fallback
Update: You can check the progress here

Signed-off-by: rickbrouwer <[email protected]>
@wozniakjan
Copy link
Member

wozniakjan commented Feb 21, 2025

/run-e2e fallback
Update: You can check the progress here

Signed-off-by: rickbrouwer <[email protected]>
Signed-off-by: rickbrouwer <[email protected]>
Signed-off-by: rickbrouwer <[email protected]>
@wozniakjan
Copy link
Member

wozniakjan commented Feb 21, 2025

/run-e2e fallback
Update: You can check the progress here

Copy link
Member

@JorTurFer JorTurFer left a comment

Choose a reason for hiding this comment

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

❤️

Copy link
Member

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

LGTM, great stuff!

@zroubalik zroubalik merged commit 4cd84f3 into kedacore:main Feb 22, 2025
20 checks passed
@rickbrouwer rickbrouwer deleted the fallback branch February 22, 2025 11:47
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.

Add Fallback option behavior for dynamic fallback calculation
4 participants