Fix panic on scaling organizational runners (#381)

Ref https://github.com/summerwind/actions-runner-controller/issues/377#issuecomment-793287133
This commit is contained in:
Yusuke Kuoka
2021-03-09 15:03:47 +09:00
committed by GitHub
parent c0b8f9d483
commit 728829be7b
2 changed files with 94 additions and 0 deletions

View File

@@ -91,6 +91,13 @@ func (r *HorizontalRunnerAutoscalerReconciler) calculateReplicasByQueuedAndInPro
return nil, fmt.Errorf("asserting runner deployment spec to detect bug: spec.template.organization should not be empty on this code path")
}
// In case it's an organizational runners deployment without any scaling metrics defined,
// we assume that the desired replicas should always be `minReplicas + capacityReservedThroughWebhook`.
// See https://github.com/summerwind/actions-runner-controller/issues/377#issuecomment-793372693
if len(metrics) == 0 {
return hra.Spec.MinReplicas, nil
}
if len(metrics[0].RepositoryNames) == 0 {
return nil, errors.New("validating autoscaling metrics: spec.autoscaling.metrics[].repositoryNames is required and must have one more more entries for organizational runner deployment")
}