diff --git a/CHANGELOG.md b/CHANGELOG.md index fb6ba017095..b8a89886a2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ Here is an overview of all new **experimental** features: - **General**: Fix regression in fallback mechanism ([#4249](https://github.com/kedacore/keda/issues/4249)) - **General**: Prevent a panic that might occur while refreshing a scaler cache ([#4092](https://github.com/kedacore/keda/issues/4092)) +- **Azure Queue Scaler**: Fix azure queue length ([#4002](https://github.com/kedacore/keda/issues/4002)) - **Azure Service Bus Scaler:** Use correct auth flows with pod identity ([#4026](https://github.com/kedacore/keda/issues/4026)|[#4123](https://github.com/kedacore/keda/issues/4123)) - **Azure Service Bus Scaler:**: Improve way clients are created to reduce amount of ARM requests ([#4262](https://github.com/kedacore/keda/issues/4262)) - **Cassandra Scaler**: Checking whether the port information is entered in the ClusterIPAddres is done correctly. ([#4110](https://github.com/kedacore/keda/issues/4110)) diff --git a/pkg/scalers/azure/azure_queue.go b/pkg/scalers/azure/azure_queue.go index e1224e29039..0a4f27a0e09 100644 --- a/pkg/scalers/azure/azure_queue.go +++ b/pkg/scalers/azure/azure_queue.go @@ -25,11 +25,7 @@ import ( "github.com/kedacore/keda/v2/pkg/util" ) -const ( - maxPeekMessages int32 = 32 -) - -// GetAzureQueueLength returns the length of a queue in int +// GetAzureQueueLength returns the length of a queue in int, see https://learn.microsoft.com/en-us/azure/storage/queues/storage-dotnet-how-to-use-queues?tabs=dotnet#get-the-queue-length func GetAzureQueueLength(ctx context.Context, httpClient util.HTTPDoer, podIdentity kedav1alpha1.AuthPodIdentity, connectionString, queueName, accountName, endpointSuffix string) (int64, error) { credential, endpoint, err := ParseAzureStorageQueueConnection(ctx, httpClient, podIdentity, connectionString, accountName, endpointSuffix) if err != nil { @@ -40,16 +36,6 @@ func GetAzureQueueLength(ctx context.Context, httpClient util.HTTPDoer, podIdent serviceURL := azqueue.NewServiceURL(*endpoint, p) queueURL := serviceURL.NewQueueURL(queueName) - visibleMessageCount, err := getVisibleCount(ctx, &queueURL, maxPeekMessages) - if err != nil { - return -1, err - } - - // Queue has less messages than we allowed to peek for, so no need to get the approximation - if visibleMessageCount < int64(maxPeekMessages) { - return visibleMessageCount, nil - } - props, err := queueURL.GetProperties(ctx) if err != nil { return -1, err @@ -57,13 +43,3 @@ func GetAzureQueueLength(ctx context.Context, httpClient util.HTTPDoer, podIdent return int64(props.ApproximateMessagesCount()), nil } - -func getVisibleCount(ctx context.Context, queueURL *azqueue.QueueURL, maxCount int32) (int64, error) { - messagesURL := queueURL.NewMessagesURL() - queue, err := messagesURL.Peek(ctx, maxCount) - if err != nil { - return 0, err - } - num := queue.NumMessages() - return int64(num), nil -}