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

add top to job requests api #4326

Merged
merged 11 commits into from
Mar 6, 2023
9 changes: 8 additions & 1 deletion pkg/scalers/azure_pipelines_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ type azurePipelinesMetadata struct {
poolID int
targetPipelinesQueueLength int64
activationTargetPipelinesQueueLength int64
jobsToFetch int
scalerIndex int
requireAllDemands bool
}
Expand Down Expand Up @@ -217,6 +218,12 @@ func parseAzurePipelinesMetadata(ctx context.Context, config *ScalerConfig, http
} else {
meta.demands = ""
}

if val, ok := config.TriggerMetadata["jobsToFetch"]; ok && val != "" {
meta.jobsToFetch = config.TriggerMetadata["jobsToFetch"]
} else {
meta.jobsToFetch = 250
}
shayki5 marked this conversation as resolved.
Show resolved Hide resolved

meta.requireAllDemands = false
if val, ok := config.TriggerMetadata["requireAllDemands"]; ok && val != "" {
Expand Down Expand Up @@ -322,7 +329,7 @@ func getAzurePipelineRequest(ctx context.Context, url string, metadata *azurePip
}

func (s *azurePipelinesScaler) GetAzurePipelinesQueueLength(ctx context.Context) (int64, error) {
url := fmt.Sprintf("%s/_apis/distributedtask/pools/%d/jobrequests?$top=250", s.metadata.organizationURL, s.metadata.poolID)
url := fmt.Sprintf("%s/_apis/distributedtask/pools/%d/jobrequests?$top=%d", s.metadata.organizationURL, s.metadata.poolID, s.metadata.jobsToFetch)
body, err := getAzurePipelineRequest(ctx, url, s.metadata, s.httpClient)
if err != nil {
return -1, err
Expand Down