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

Adding Lag-dependent implementation of Redis streams scaler #4592

Merged
merged 38 commits into from Jun 21, 2023

Conversation

mikelam-us
Copy link
Contributor

@mikelam-us mikelam-us commented May 31, 2023

Provide a description of what has been changed

Checklist

This is a PR for a Redis scaler implementation based optionally on the lag count of a given consumer group. Previously, the scaler operated based either on the number of pending entries (as returned by XPENDING) or the stream length (as returned by XLEN), neither of which accurately reflect how the job should actually be scaled. The lag-based implementation should remedy this since consumer group lag much more accurately reflects how the job should be scaled. The implementation is backwards compatible with all other parts of keda, though it should be noted that Redis 7.0.0+ is required as XINFO lag, the Redis command on which this implementation depends, is absent in earlier versions.

All lag-specific unit tests have been added to redis_scaler_test.go. End-to-end tests are in redis_sentinel_streams_lag_test.go and redis_cluster_streams_lag_test.go.

Related issues: #4277, #3127

@mikelam-us mikelam-us requested a review from a team as a code owner May 31, 2023 01:08
@mikelam-us mikelam-us marked this pull request as draft May 31, 2023 01:08
Copy link

@krishnadurai krishnadurai left a comment

Choose a reason for hiding this comment

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

@mikelam-us can you please address these comments I've left on your PR?

config/manager/kustomization.yaml Outdated Show resolved Hide resolved
config/metrics-server/kustomization.yaml Outdated Show resolved Hide resolved
config/webhooks/kustomization.yaml Outdated Show resolved Hide resolved
pkg/scalers/redis_streams_scaler.go Outdated Show resolved Hide resolved
pkg/scalers/redis_streams_scaler.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
pkg/scalers/redis_streams_scaler.go Outdated Show resolved Hide resolved
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
…renamed test files

Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
@zroubalik
Copy link
Member

zroubalik commented Jun 6, 2023

/run-e2e redis
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.

Looking good. I left one comment inline
BTW, the standalone e2e test case is still pending 🙏

@mikelam-us mikelam-us marked this pull request as ready for review June 7, 2023 16:30
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
@mikelam-us mikelam-us marked this pull request as draft June 7, 2023 17:51
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
@mikelam-us mikelam-us marked this pull request as ready for review June 7, 2023 18:43
@mikelam-us
Copy link
Contributor Author

Hello all! I've addressed all the previous comments, so it would be great if you all could take another look just to make sure I'm not missing anything! Thanks in advance!

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.

Sorry for the insistence, but could you cover redis_standalone case with e2e test too (other cases are already covered for that scenario)?
image

Apart from that, just a small comment inline

@JorTurFer
Copy link
Member

/e2e-test redis

Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <michael.lam@aixplain.com>
@mikelam-us
Copy link
Contributor Author

Jorge, thank you so much for your comments on the e2e tests. While we were working on implementing these tests, we caught some interesting behavior with Redis. The initial consumer Deployment isn’t able to register its consumerGroup because by the time it is ready or otherwise, the producer Job hasn’t created the stream as it is not deployed by then. Now, since there is no lagCount, the consumer Deployment is scaled down to 0. We need the XLEN for the stream in order for our system to start (scale-up from zero) the consumer Deployments. We are dependent on the XLEN for start-up.
On all other scenarios, we default to lagCount from the XINFO because after the start-up event, we can reliably get the lagCount from the registered consumer group of our consumer that was brought up once already by the start-up process.
We spend the past week implementing this fix, and this should be reflected in the current PR. It would be great if you could take a look! Thanks!

Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
@JorTurFer
Copy link
Member

JorTurFer commented Jun 20, 2023

/run-e2e redis
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.

Looking good, only 1 small change in the key name and that's all here

pkg/scalers/redis_streams_scaler.go Outdated Show resolved Hide resolved
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.

LGTM!
Thanks a lot for the feature ❤️

@JorTurFer
Copy link
Member

JorTurFer commented Jun 20, 2023

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

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

thanks for the contribution!

@zroubalik zroubalik merged commit 96fc64c into kedacore:main Jun 21, 2023
22 checks passed
SpiritZhou pushed a commit to SpiritZhou/keda that referenced this pull request Jun 30, 2023
…#4592)

Signed-off-by: mikelam-us <michael.lam@aixplain.com>
Signed-off-by: mikelam-us <69995279+mikelam-us@users.noreply.github.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: mikelam-us <michael.lam@aixplain.com>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
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.

None yet

5 participants