Skip to content

Add Fallback option behavior for dynamic fallback calculation#6464

Merged
zroubalik merged 20 commits intokedacore:mainfrom
rickbrouwer:fallback
Feb 22, 2025
Merged

Add Fallback option behavior for dynamic fallback calculation#6464
zroubalik merged 20 commits intokedacore:mainfrom
rickbrouwer:fallback

Conversation

@rickbrouwer
Copy link
Copy Markdown
Member

@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

Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
@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
Comment thread pkg/scaling/executor/scale_scaledobjects_test.go Outdated
Comment thread pkg/scaling/executor/scale_scaledobjects_test.go Outdated
Comment thread pkg/scaling/executor/scale_scaledobjects_test.go Outdated
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
Copy link
Copy Markdown
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!

Comment thread pkg/fallback/fallback.go Outdated
Comment thread apis/keda/v1alpha1/scaledobject_types.go Outdated
@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 <rickbrouwer@gmail.com>
Copy link
Copy Markdown
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

Comment thread apis/keda/v1alpha1/scaledobject_types.go
Comment thread apis/keda/v1alpha1/scaledobject_types.go Outdated
rickbrouwer and others added 3 commits January 17, 2025 15:47
Co-authored-by: Jan Wozniak <wozniak.jan@gmail.com>
Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
Co-authored-by: Jan Wozniak <wozniak.jan@gmail.com>
Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
@JorTurFer
Copy link
Copy Markdown
Member

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

@rickbrouwer rickbrouwer force-pushed the fallback branch 2 times, most recently from fe1d3a0 to 76d35eb Compare February 6, 2025 14:43
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
Copy link
Copy Markdown
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 <rickbrouwer@gmail.com>
@rickbrouwer
Copy link
Copy Markdown
Member Author

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

added an e2e test

Comment thread apis/keda/v1alpha1/scaledobject_types.go
Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
@wozniakjan
Copy link
Copy Markdown
Member

wozniakjan commented Feb 20, 2025

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

Comment thread tests/internals/fallback/fallback_test.go
Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
@wozniakjan
Copy link
Copy Markdown
Member

wozniakjan commented Feb 21, 2025

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

Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
@wozniakjan
Copy link
Copy Markdown
Member

wozniakjan commented Feb 21, 2025

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

Copy link
Copy Markdown
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
Copy Markdown
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
@rickbrouwer rickbrouwer deleted the fallback branch February 22, 2025 11:47
mittalvaibhav1 pushed a commit to mittalvaibhav1/keda that referenced this pull request Apr 26, 2025
…core#6464)

Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
Co-authored-by: Jan Wozniak <wozniak.jan@gmail.com>
Signed-off-by: mittalvaibhav1 <mittalvaibhavandroid@gmail.com>
dpochopsky pushed a commit to dpochopsky/keda that referenced this pull request Sep 12, 2025
…core#6464)

Signed-off-by: rickbrouwer <rickbrouwer@gmail.com>
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
Co-authored-by: Jan Wozniak <wozniak.jan@gmail.com>
Signed-off-by: David Pochopsky <david.pochopsky@united.com>
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