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

fix(Redis Streams): Allow default value of 0 for activationLagCount #6481

Merged
merged 3 commits into from
Jan 18, 2025

Conversation

rickbrouwer
Copy link
Contributor

@rickbrouwer rickbrouwer commented Jan 12, 2025

This PR was created due to a bug found and reported as an issue #6478.

The documentation Redis Streams states that a default of 0 is allowed. In version v2.15.1 seems that be possible.
In v2.16 a check is applied with a refactoring where the value 0 is not allowed:

if r.ActivationLagCount == 0 {
	err := errors.New("activationLagCount required for Redis lag")
	return err
}

The code contains the following line:

return []external_metrics.ExternalMetricValue{metric}, metricCount > s.metadata.ActivationLagCount, nil

The second return value (the boolean) determines whether the scaler is active. This becomes true if metricCount > ActivationLagCount.
Because ActivationLagCount cannot be 0, this means that there must be at least 2 messages before scaling is activated. This means that scaling can never be activated on 1 message.

Checklist

Fixes #6478

@rickbrouwer rickbrouwer requested a review from a team as a code owner January 12, 2025 19:19
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.

Awesome catch! 🚀

Just a small suggestion inline and another here, could we add a unit test to not break this again in the future?

pkg/scalers/redis_streams_scaler.go Show resolved Hide resolved
Signed-off-by: Rick Brouwer <[email protected]>
@JorTurFer
Copy link
Member

JorTurFer commented Jan 18, 2025

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

@JorTurFer JorTurFer merged commit 817d9ca into kedacore:main Jan 18, 2025
20 checks passed
@rickbrouwer rickbrouwer deleted the issue-6478 branch January 18, 2025 19:12
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.

Redis Streams Scaler Does Not Trigger on a Single Message
2 participants