From 822a0decd47f0ba562f39417710a2dbd1ed9dfe5 Mon Sep 17 00:00:00 2001 From: patst Date: Tue, 7 Feb 2023 19:28:59 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Jorge Turrado Ferrero Signed-off-by: patst --- CHANGELOG.md | 2 +- pkg/scalers/azure_pipelines_scaler.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a920400621d..5fd7a582d3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,9 +60,9 @@ Here is an overview of all new **experimental** features: ### Improvements -- **Azure Pipelines Scaler:** New configuration parameter `requireAllDemands` to scale only if jobs request all demands provided by the scaling definition ([#4138](https://github.com/kedacore/keda/issues/4138)) - **General**: Add a warning when KEDA run outside supported k8s versions ([#4130](https://github.com/kedacore/keda/issues/4130)) - **General**: Use (self-signed) certificates for all the communications (internals and externals) ([#3931](https://github.com/kedacore/keda/issues/3931)) +- **Azure Pipelines Scaler:** New configuration parameter `requireAllDemands` to scale only if jobs request all demands provided by the scaling definition ([#4138](https://github.com/kedacore/keda/issues/4138)) - **Hashicorp Vault**: Add support to secrets backend version 1 ([#2645](https://github.com/kedacore/keda/issues/2645)) - **RabbitMQ Scaler**: Add TLS support ([#967](https://github.com/kedacore/keda/issues/967)) - **Redis Scalers**: Add support to Redis 7 ([#4052](https://github.com/kedacore/keda/issues/4052)) diff --git a/pkg/scalers/azure_pipelines_scaler.go b/pkg/scalers/azure_pipelines_scaler.go index 4d3dd6ee528..967eeb921f3 100644 --- a/pkg/scalers/azure_pipelines_scaler.go +++ b/pkg/scalers/azure_pipelines_scaler.go @@ -384,10 +384,11 @@ func getCanAgentDemandFulfilJob(jr JobRequest, metadata *azurePipelinesMetadata) } } } + matchDemands := countDemands == len(demandsReq)-1 if metadata.requireAllDemands { - return countDemands == len(demandsAvail) && len(demandsAvail) == len(demandsReq)-1 + return matchDemands && countDemands == len(demandsAvail) } - return countDemands == len(demandsReq)-1 + return matchDemands } // Determine if the Job and Parent Agent Template have matching capabilities