Skip to content

Commit

Permalink
fix(Redis Streams): Allow default value of 0 for activationLagCount (#…
Browse files Browse the repository at this point in the history
…6481)

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

Signed-off-by: rickbrouwer <[email protected]>

* Add unit test

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

---------

Signed-off-by: rickbrouwer <[email protected]>
Signed-off-by: Rick Brouwer <[email protected]>
  • Loading branch information
rickbrouwer authored Jan 18, 2025
1 parent e667de1 commit 817d9ca
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
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 {
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

0 comments on commit 817d9ca

Please sign in to comment.