diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e85235b4e1..f5202b69244 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -138,6 +138,7 @@ New deprecation(s): - **AWS Secret Manager**: Pod identity overrides are honored ([#6195](https://github.com/kedacore/keda/issues/6195)) - **AWS SQS Scaler**: Improve error handling for SQS queue metrics ([#6178](https://github.com/kedacore/keda/issues/6178)) - **Azure Event Hub Scaler**: Checkpointer errors are correctly handled ([#6084](https://github.com/kedacore/keda/issues/6084)) +- **JetStream**: NATS API uses account ID and not account name to filter by account ([#6415](https://github.com/kedacore/keda/pull/6415)) - **Metrics API Scaler**: Prometheus metrics can have multiple labels ([#6077](https://github.com/kedacore/keda/issues/6077)) ### Deprecations diff --git a/pkg/scalers/nats_jetstream_scaler.go b/pkg/scalers/nats_jetstream_scaler.go index 47a0bbe1f36..33b8b7b08be 100644 --- a/pkg/scalers/nats_jetstream_scaler.go +++ b/pkg/scalers/nats_jetstream_scaler.go @@ -64,6 +64,7 @@ type jetStreamCluster struct { } type accountDetail struct { + ID string `json:"id"` Name string `json:"name"` Streams []*streamDetail `json:"stream_detail"` } @@ -278,7 +279,7 @@ func (s *natsJetStreamScaler) getNATSJetstreamMonitoringData(ctx context.Context } for _, jetStreamAccount := range jetStreamAccountResp.Accounts { - if jetStreamAccount.Name == s.metadata.account { + if jetStreamAccount.ID == s.metadata.account { for _, stream := range jetStreamAccount.Streams { if stream.Name == s.metadata.stream { for _, consumer := range stream.Consumers { @@ -305,7 +306,7 @@ func (s *natsJetStreamScaler) setNATSJetStreamMonitoringData(jetStreamAccountRes // find and assign the stream that we are looking for. for _, jsAccount := range jetStreamAccountResp.Accounts { - if jsAccount.Name == s.metadata.account { + if jsAccount.ID == s.metadata.account { for _, stream := range jsAccount.Streams { if stream.Name == s.metadata.stream { s.stream = stream diff --git a/pkg/scalers/nats_jetstream_scaler_test.go b/pkg/scalers/nats_jetstream_scaler_test.go index c77811011f7..8c35c4ad0c0 100644 --- a/pkg/scalers/nats_jetstream_scaler_test.go +++ b/pkg/scalers/nats_jetstream_scaler_test.go @@ -131,7 +131,7 @@ var testNATSJetStreamMockResponses = []parseNATSJetStreamMockResponsesTestData{ 0, "s0-nats-jetstream-mystream", }, &jetStreamEndpointResponse{ - Accounts: []accountDetail{{Name: "$G", + Accounts: []accountDetail{{Name: "$G", ID: "$G", Streams: []*streamDetail{{Name: "mystream", Consumers: []consumerDetail{{Name: "pull_consumer"}}, }}, @@ -145,7 +145,7 @@ var testNATSJetStreamMockResponses = []parseNATSJetStreamMockResponsesTestData{ 0, "s0-nats-jetstream-mystream", }, &jetStreamEndpointResponse{ - Accounts: []accountDetail{{Name: "$G", + Accounts: []accountDetail{{Name: "$G", ID: "$G", Streams: []*streamDetail{{Name: "mystream", Consumers: []consumerDetail{{Name: "pull_consumer", NumPending: 100}}, }}, @@ -159,7 +159,7 @@ var testNATSJetStreamMockResponses = []parseNATSJetStreamMockResponsesTestData{ 0, "s0-nats-jetstream-mystream", }, &jetStreamEndpointResponse{ - Accounts: []accountDetail{{Name: "$G", + Accounts: []accountDetail{{Name: "$G", ID: "$G", Streams: []*streamDetail{{Name: "mystream", State: streamState{LastSequence: 1}, Consumers: []consumerDetail{{Name: "pull_consumer_bad", NumPending: 100}}, }}, @@ -173,7 +173,7 @@ var testNATSJetStreamMockResponses = []parseNATSJetStreamMockResponsesTestData{ 0, "s0-nats-jetstream-mystream", }, &jetStreamEndpointResponse{ - Accounts: []accountDetail{{Name: "$G", + Accounts: []accountDetail{{Name: "$G", ID: "$G", Streams: []*streamDetail{{Name: "mystreamBad", State: streamState{LastSequence: 1}, Consumers: []consumerDetail{{Name: "pull_consumer", NumPending: 100}}, }}, @@ -187,7 +187,7 @@ var testNATSJetStreamMockResponses = []parseNATSJetStreamMockResponsesTestData{ 0, "s0-nats-jetstream-mystream", }, &jetStreamEndpointResponse{ - Accounts: []accountDetail{{Name: "$G", + Accounts: []accountDetail{{Name: "$G", ID: "$G", Streams: []*streamDetail{{Name: "mystream", Consumers: []consumerDetail{{Name: "pull_consumer", NumPending: 100}}, }}, @@ -202,7 +202,7 @@ var testNATSJetStreamMockResponses = []parseNATSJetStreamMockResponsesTestData{ }, &jetStreamEndpointResponse{ MetaCluster: metaCluster{ClusterSize: 3}, - Accounts: []accountDetail{{Name: "$G", + Accounts: []accountDetail{{Name: "$G", ID: "$G", Streams: []*streamDetail{{Name: "mystream", Consumers: []consumerDetail{{Name: "pull_consumer", NumPending: 100, Cluster: consumerCluster{Leader: "leader"}}}, }}, @@ -217,7 +217,7 @@ var testNATSJetStreamMockResponses = []parseNATSJetStreamMockResponsesTestData{ }, &jetStreamEndpointResponse{ MetaCluster: metaCluster{ClusterSize: 3}, - Accounts: []accountDetail{{Name: "$G", + Accounts: []accountDetail{{Name: "$G", ID: "$G", Streams: []*streamDetail{{Name: "mystream"}}, }}, }, false, true},