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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

leodip
Copy link

@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.

@leodip leodip force-pushed the 4478-add-queueLengthStrategy branch from d30026d to 9b5fa4a Compare June 9, 2024 13:10
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.

@leodip leodip force-pushed the 4478-add-queueLengthStrategy branch from 0f64726 to a95588d Compare June 9, 2024 13:44
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
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
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 leodip force-pushed the 4478-add-queueLengthStrategy branch from bf331d5 to e2421c0 Compare July 1, 2024 07:35
…queueLengthStrategy

Signed-off-by: Leonardo D'Ippolito <contact@leodip.com>
@leodip leodip force-pushed the 4478-add-queueLengthStrategy branch from e2421c0 to 6bd92a1 Compare July 1, 2024 07:43
@leodip
Copy link
Author

leodip commented Jul 1, 2024

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

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.

None yet

3 participants