Skip to content

Add fetchUnfinishedJobsOnly property to Azure Pipelines scaler trigger metadata#6894

Merged
zroubalik merged 11 commits intokedacore:mainfrom
wbpascal:feature/azurePipelinesFetchPendingJobsOnlySigned
Aug 26, 2025
Merged

Add fetchUnfinishedJobsOnly property to Azure Pipelines scaler trigger metadata#6894
zroubalik merged 11 commits intokedacore:mainfrom
wbpascal:feature/azurePipelinesFetchPendingJobsOnlySigned

Conversation

@wbpascal
Copy link
Contributor

@wbpascal wbpascal commented Jul 8, 2025

Adds a new property fetchUnfinishedJobsOnly to the trigger metadata of the Azure Pipelines scaler that accepts a boolean value. If the value true is given, the query parameter completedRequestCount=0 is given when requesting the pipeline queue length. If the value is false, previous logic is applied because completedRequestCount cannot be used at the same time as the $top query parameter. By default, the value false is used to not break existing behavior.

Checklist

Fixes #6819

Relates to #6148

wbpascal added 5 commits July 8, 2025 16:06
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
t.Run(testData.testName, func(t *testing.T) {
var apiStub = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write(buildLoadJSON())
Copy link

Choose a reason for hiding this comment

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

Semgrep identified a blocking 🔴 issue in your code:
Detected directly writing or similar in 'http.ResponseWriter.write()'. This bypasses HTML escaping that prevents cross-site scripting vulnerabilities. Instead, use the 'html/template' package and render data using 'template.Execute()'.

To resolve this comment:

🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by no-direct-write-to-responsewriter.

You can view more details about this finding in the Semgrep AppSec Platform.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/fp This is part of a test mock. As this is not being done during actual runtime, this should be acceptable here.

Copy link
Member

Choose a reason for hiding this comment

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

/fp This is part of a test mock. As this is not being done during actual runtime, this should be acceptable here.

This better represents the new API query parameter
that is being used as it also returns jobs that
are already in progress/running and not only
pending jobs.

Additionally, it is now allowed to specify `parent`
and `fetchUnfinishedJobsOnly` at the same time.

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
@wbpascal wbpascal changed the title Add fetchPendingJobsOnly property to Azure Pipelines scaler trigger metadata Add fetchUnfinishedJobsOnly property to Azure Pipelines scaler trigger metadata Jul 9, 2025
@wbpascal wbpascal marked this pull request as ready for review July 9, 2025 06:43
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
@zroubalik zroubalik requested a review from Copilot July 21, 2025 15:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new fetchUnfinishedJobsOnly property to the Azure Pipelines scaler trigger metadata that allows filtering for only unfinished pipeline jobs. When set to true, it uses the completedRequestCount=0 query parameter instead of the existing $top parameter, which provides more targeted job filtering while maintaining compatibility with parent agent configurations.

  • Adds fetchUnfinishedJobsOnly boolean property with validation to prevent conflicts with existing parameters
  • Refactors URL generation logic into a separate method for better testability
  • Implements comprehensive test coverage for URL generation scenarios

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pkg/scalers/azure_pipelines_scaler.go Adds new metadata property, validation logic, and URL generation method
pkg/scalers/azure_pipelines_scaler_test.go Adds test cases for parameter validation and URL generation scenarios
CHANGELOG.md Documents the new feature addition
Comments suppressed due to low confidence (2)

pkg/scalers/azure_pipelines_scaler_test.go:465

  • The test should verify the specific error or use a more descriptive assertion. Simply calling t.Fail() without context makes debugging failures difficult.
			if err != nil {

pkg/scalers/azure_pipelines_scaler_test.go:470

  • The test should provide more descriptive failure messages. Consider using t.Errorf() to show expected vs actual values instead of just calling t.Fail().
			if queueURL != expectedURL {

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
@JorTurFer
Copy link
Member

JorTurFer commented Aug 16, 2025

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

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
@wbpascal wbpascal force-pushed the feature/azurePipelinesFetchPendingJobsOnlySigned branch from 67f1339 to 8713390 Compare August 19, 2025 15:38
@zroubalik
Copy link
Member

zroubalik commented Aug 26, 2025

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

…gned

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
@zroubalik zroubalik requested a review from a team as a code owner August 26, 2025 09:31
@keda-automation keda-automation requested a review from a team August 26, 2025 09:32
@zroubalik zroubalik enabled auto-merge (squash) August 26, 2025 09:32
@zroubalik zroubalik disabled auto-merge August 26, 2025 11:09
@zroubalik zroubalik merged commit f553e4a into kedacore:main Aug 26, 2025
21 of 24 checks passed
@wbpascal
Copy link
Contributor Author

Thank you very much for merging :)

@wbpascal wbpascal deleted the feature/azurePipelinesFetchPendingJobsOnlySigned branch August 27, 2025 04:27
dpochopsky pushed a commit to dpochopsky/keda that referenced this pull request Sep 12, 2025
…ger metadata (kedacore#6894)

* Add fetchPendingJobsOnly to Azure Pipeline scaler

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Add additional validation for trigger metadata

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* test: add tests for new azure pipelines scaler functionality

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Update changelog

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Revert to old default value for jobsToFetch

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Rename new property to fetchUnfinishedJobsOnly

This better represents the new API query parameter
that is being used as it also returns jobs that
are already in progress/running and not only
pending jobs.

Additionally, it is now allowed to specify `parent`
and `fetchUnfinishedJobsOnly` at the same time.

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Update CHANGELOG.md with new property name

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Fix typo in test case name

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Document decision on why branches are not merged

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

---------

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Zbynek Roubalik <zroubalik@gmail.com>
Signed-off-by: David Pochopsky <david.pochopsky@united.com>
jmickey pushed a commit to jmickey/keda that referenced this pull request Sep 30, 2025
…ger metadata (kedacore#6894)

* Add fetchPendingJobsOnly to Azure Pipeline scaler

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Add additional validation for trigger metadata

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* test: add tests for new azure pipelines scaler functionality

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Update changelog

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Revert to old default value for jobsToFetch

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Rename new property to fetchUnfinishedJobsOnly

This better represents the new API query parameter
that is being used as it also returns jobs that
are already in progress/running and not only
pending jobs.

Additionally, it is now allowed to specify `parent`
and `fetchUnfinishedJobsOnly` at the same time.

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Update CHANGELOG.md with new property name

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Fix typo in test case name

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Document decision on why branches are not merged

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

---------

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Zbynek Roubalik <zroubalik@gmail.com>
alt-dima pushed a commit to alt-dima/keda that referenced this pull request Dec 13, 2025
…ger metadata (kedacore#6894)

* Add fetchPendingJobsOnly to Azure Pipeline scaler

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Add additional validation for trigger metadata

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* test: add tests for new azure pipelines scaler functionality

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Update changelog

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Revert to old default value for jobsToFetch

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Rename new property to fetchUnfinishedJobsOnly

This better represents the new API query parameter
that is being used as it also returns jobs that
are already in progress/running and not only
pending jobs.

Additionally, it is now allowed to specify `parent`
and `fetchUnfinishedJobsOnly` at the same time.

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Update CHANGELOG.md with new property name

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Fix typo in test case name

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Document decision on why branches are not merged

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

---------

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Zbynek Roubalik <zroubalik@gmail.com>
Signed-off-by: Dmitriy Altuhov <altuhovd@gmail.com>
tangobango5 pushed a commit to tangobango5/keda that referenced this pull request Dec 22, 2025
…ger metadata (kedacore#6894)

* Add fetchPendingJobsOnly to Azure Pipeline scaler

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Add additional validation for trigger metadata

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* test: add tests for new azure pipelines scaler functionality

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Update changelog

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Revert to old default value for jobsToFetch

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Rename new property to fetchUnfinishedJobsOnly

This better represents the new API query parameter
that is being used as it also returns jobs that
are already in progress/running and not only
pending jobs.

Additionally, it is now allowed to specify `parent`
and `fetchUnfinishedJobsOnly` at the same time.

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Update CHANGELOG.md with new property name

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Fix typo in test case name

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Document decision on why branches are not merged

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

---------

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Zbynek Roubalik <zroubalik@gmail.com>
tangobango5 pushed a commit to tangobango5/keda that referenced this pull request Feb 13, 2026
…ger metadata (kedacore#6894)

* Add fetchPendingJobsOnly to Azure Pipeline scaler

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Add additional validation for trigger metadata

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* test: add tests for new azure pipelines scaler functionality

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Update changelog

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Revert to old default value for jobsToFetch

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Rename new property to fetchUnfinishedJobsOnly

This better represents the new API query parameter
that is being used as it also returns jobs that
are already in progress/running and not only
pending jobs.

Additionally, it is now allowed to specify `parent`
and `fetchUnfinishedJobsOnly` at the same time.

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Update CHANGELOG.md with new property name

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Fix typo in test case name

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

* Document decision on why branches are not merged

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>

---------

Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Zbynek Roubalik <zroubalik@gmail.com>
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.

[Azure Pipeline Scaler] Scaler logic is limited to 200 jobs, even with the $top query parameter

4 participants