Add fetchUnfinishedJobsOnly property to Azure Pipelines scaler trigger metadata#6894
Conversation
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()) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
/fp This is part of a test mock. As this is not being done during actual runtime, this should be acceptable here.
There was a problem hiding this comment.
/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>
fetchPendingJobsOnly property to Azure Pipelines scaler trigger metadatafetchUnfinishedJobsOnly property to Azure Pipelines scaler trigger metadata
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
There was a problem hiding this comment.
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
fetchUnfinishedJobsOnlyboolean 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>
|
/run-e2e pipeline |
Signed-off-by: Pascal Wiedenbeck <pascalw98@gmail.com>
67f1339 to
8713390
Compare
|
/run-e2e pipeline |
…gned Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
|
Thank you very much for merging :) |
…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>
…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>
…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>
…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>
…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>
Adds a new property
fetchUnfinishedJobsOnlyto the trigger metadata of the Azure Pipelines scaler that accepts a boolean value. If the valuetrueis given, the query parametercompletedRequestCount=0is given when requesting the pipeline queue length. If the value isfalse, previous logic is applied becausecompletedRequestCountcannot be used at the same time as the$topquery parameter. By default, the valuefalseis used to not break existing behavior.Checklist
fetchUnfinishedJobsOnlytrigger property in Azure Pipelines scaler keda-docs#1583)Fixes #6819
Relates to #6148