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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Here is an overview of all new **experimental** features:

- **General**: Fix event text when deactivation fails ([#6469](https://github.com/kedacore/keda/issues/6469))
- **AWS Scalers**: Add AWS region to the AWS Config Cache key ([#6128](https://github.com/kedacore/keda/issues/6128))
- **Redis Streams**: Allow default value of 0 for activationLagCount ([#6478](https://github.com/kedacore/keda/issues/6478))
- **Selenium Grid**: Scaler logic on platformName is set empty or `any` ([#6477](https://github.com/kedacore/keda/issues/6477))

### Deprecations
Expand Down
7 changes: 1 addition & 6 deletions pkg/scalers/redis_streams_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type redisStreamsMetadata struct {
ConsumerGroupName string `keda:"name=consumerGroup, order=triggerMetadata, optional"`
DatabaseIndex int `keda:"name=databaseIndex, order=triggerMetadata, optional"`
ConnectionInfo redisConnectionInfo `keda:"optional"`
ActivationLagCount int64 `keda:"name=activationLagCount, order=triggerMetadata, optional"`
ActivationLagCount int64 `keda:"name=activationLagCount, order=triggerMetadata, default=0"`
MetadataEnableTLS string `keda:"name=enableTLS, order=triggerMetadata, optional"`
AuthParamEnableTLS string `keda:"name=tls, order=authParams, optional"`
}
Expand All @@ -82,11 +82,6 @@ func (r *redisStreamsMetadata) Validate() error {
if r.TargetLag != 0 {
r.scaleFactor = lagFactor
r.TargetPendingEntriesCount = 0

if r.ActivationLagCount == 0 {
JorTurFer marked this conversation as resolved.
Show resolved Hide resolved
err := errors.New("activationLagCount required for Redis lag")
return err
}
} else {
r.scaleFactor = xPendingFactor
}
Expand Down
24 changes: 24 additions & 0 deletions pkg/scalers/redis_streams_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,30 @@ func TestParseRedisClusterStreamsMetadata(t *testing.T) {
},
wantErr: nil,
},
{
name: "zero activation lag count with lag count is allowed",
metadata: map[string]string{
"stream": "my-stream",
"lagCount": "7",
"activationLagCount": "0",
"consumerGroup": "consumer1",
},
authParams: map[string]string{
"addresses": ":7001, :7002",
},
wantMeta: &redisStreamsMetadata{
StreamName: "my-stream",
TargetPendingEntriesCount: 0,
TargetLag: 7,
ActivationLagCount: 0,
ConsumerGroupName: "consumer1",
ConnectionInfo: redisConnectionInfo{
Addresses: []string{":7001", ":7002"},
},
scaleFactor: lagFactor,
},
wantErr: nil,
},
{
name: "address is defined in auth params",
metadata: map[string]string{
Expand Down
Loading