Skip to content

Update GetAzureQueueLength in azure queue scaler, to support different queue length strategies.#5875

Merged
zroubalik merged 1 commit intokedacore:mainfrom
leodip:4478-add-queueLengthStrategy
Jul 30, 2024
Merged

Update GetAzureQueueLength in azure queue scaler, to support different queue length strategies.#5875
zroubalik merged 1 commit intokedacore:mainfrom
leodip:4478-add-queueLengthStrategy

Conversation

@leodip
Copy link
Contributor

@leodip leodip commented Jun 9, 2024

This PR is an attempt to solve #4478

It adds a new configuration option queueLengthStrategy to the Azure Storage Queue scaler, where you can set the value of default or visibleonly.

default: Considers both visible and invisible messages.
visibleonly: Uses Peek to count only visible messages. If the count of visible messages is 32 or higher, it falls back to the default strategy, counting both visible and invisible messages.

visibleonly will, in practice, use the previous behaviour, as before #4003 was merged.

Docs PR: kedacore/keda-docs#1406.

I've created this change to the best of my ability. However, it hasn't been tested. I would appreciate if someone could help with testing, or giving directions on how to test.

Thanks!

@leodip leodip requested a review from a team as a code owner June 9, 2024 12:56
})

t.Run("Invalid base64 connection string", func(t *testing.T) {
length, err := GetAzureQueueLength(context.TODO(), kedav1alpha1.AuthPodIdentity{}, "DefaultEndpointsProtocol=https;AccountName=name;AccountKey=key==;EndpointSuffix=core.windows.net", "queueName", "", "", "")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider to use well-defined context

Ignore this finding from context-todo.

t.Error("Expected error to contain base64 error message, but got", err.Error())
}
t.Run("Empty connection string", func(t *testing.T) {
length, err := GetAzureQueueLength(context.TODO(), kedav1alpha1.AuthPodIdentity{}, "", "queueName", "", "", "")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider to use well-defined context

Ignore this finding from context-todo.

@semgrep-app
Copy link

semgrep-app bot commented Jun 9, 2024

Semgrep found 2 context-todo findings:

Consider to use well-defined context

Ignore this finding from context-todo.

return int64(props.ApproximateMessagesCount()), nil
}

// Default strategy (visible + invisible messages)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per kedacore/keda-docs#1406 (comment) I don't think default is a good name nor do we even use it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I have renamed it to 'all'.

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.

Looking good! Could you replace the magic string with a constant?

@leodip
Copy link
Contributor Author

leodip commented Jun 24, 2024

Looking good! Could you replace the magic string with a constant?

Thanks, hope the new commit makes it better.

@tomkerkhove
Copy link
Member

@leodip Can you fix merge conflicts please?

@leodip
Copy link
Contributor Author

leodip commented Jul 1, 2024

@tomkerkhove I've squashed and rebased - conflicts should be solved now.

@SpiritZhou
Copy link
Contributor

SpiritZhou commented Jul 11, 2024

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

…queueLengthStrategy

Signed-off-by: Leonardo D'Ippolito <contact@leodip.com>
@JorTurFer
Copy link
Member

JorTurFer commented Jul 30, 2024

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

@zroubalik zroubalik merged commit 343396b into kedacore:main Jul 30, 2024
JorTurFer pushed a commit to JorTurFer/keda that referenced this pull request Oct 7, 2024
…queueLengthStrategy (kedacore#5875)

Signed-off-by: Leonardo D'Ippolito <contact@leodip.com>
Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>
@rickbrouwer rickbrouwer mentioned this pull request Oct 25, 2024
3 tasks
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.

5 participants