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

Merged
merged 1 commit into from
Jul 30, 2024

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.

@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
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 leodip force-pushed the 4478-add-queueLengthStrategy branch 2 times, most recently from e2421c0 to 6bd92a1 Compare July 1, 2024 07:43
@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 JorTurFer force-pushed the 4478-add-queueLengthStrategy branch from 6bd92a1 to be22628 Compare July 30, 2024 09:29
@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
19 checks passed
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