Remove the default `githubEvent: {}` requiring a event to be defined (#1379)
Ref #1358
This commit is contained in:
parent
3ba7179995
commit
1551f3b5fc
|
|
@ -668,16 +668,29 @@ HRA:
|
||||||
|
|
||||||
if len(hra.Spec.ScaleUpTriggers) > 1 {
|
if len(hra.Spec.ScaleUpTriggers) > 1 {
|
||||||
autoscaler.Log.V(1).Info("Skipping this HRA as it has too many ScaleUpTriggers to be used in workflow_job based scaling", "hra", hra.Name)
|
autoscaler.Log.V(1).Info("Skipping this HRA as it has too many ScaleUpTriggers to be used in workflow_job based scaling", "hra", hra.Name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(hra.Spec.ScaleUpTriggers) == 0 {
|
||||||
|
autoscaler.Log.V(1).Info("Skipping this HRA as it has no ScaleUpTriggers configured", "hra", hra.Name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
scaleUpTrigger := hra.Spec.ScaleUpTriggers[0]
|
||||||
|
|
||||||
|
if scaleUpTrigger.GitHubEvent == nil {
|
||||||
|
autoscaler.Log.V(1).Info("Skipping this HRA as it has no `githubEvent` scale trigger configured", "hra", hra.Name)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var duration metav1.Duration
|
if scaleUpTrigger.GitHubEvent.WorkflowJob == nil {
|
||||||
|
autoscaler.Log.V(1).Info("Skipping this HRA as it has no `githubEvent.workflowJob` scale trigger configured", "hra", hra.Name)
|
||||||
|
|
||||||
if len(hra.Spec.ScaleUpTriggers) > 0 {
|
continue
|
||||||
duration = hra.Spec.ScaleUpTriggers[0].Duration
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
duration := scaleUpTrigger.Duration
|
||||||
if duration.Duration <= 0 {
|
if duration.Duration <= 0 {
|
||||||
// Try to release the reserved capacity after at least 10 minutes by default,
|
// Try to release the reserved capacity after at least 10 minutes by default,
|
||||||
// we won't end up in the reserved capacity remained forever in case GitHub somehow stopped sending us "completed" workflow_job events.
|
// we won't end up in the reserved capacity remained forever in case GitHub somehow stopped sending us "completed" workflow_job events.
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,13 @@ func TestWebhookWorkflowJob(t *testing.T) {
|
||||||
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
||||||
Name: "test-name",
|
Name: "test-name",
|
||||||
},
|
},
|
||||||
|
ScaleUpTriggers: []actionsv1alpha1.ScaleUpTrigger{
|
||||||
|
{
|
||||||
|
GitHubEvent: &actionsv1alpha1.GitHubEventScaleUpTriggerSpec{
|
||||||
|
WorkflowJob: &actionsv1alpha1.WorkflowJobSpec{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,6 +184,13 @@ func TestWebhookWorkflowJob(t *testing.T) {
|
||||||
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
||||||
Name: "test-name",
|
Name: "test-name",
|
||||||
},
|
},
|
||||||
|
ScaleUpTriggers: []actionsv1alpha1.ScaleUpTrigger{
|
||||||
|
{
|
||||||
|
GitHubEvent: &actionsv1alpha1.GitHubEventScaleUpTriggerSpec{
|
||||||
|
WorkflowJob: &actionsv1alpha1.WorkflowJobSpec{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -217,6 +231,13 @@ func TestWebhookWorkflowJob(t *testing.T) {
|
||||||
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
||||||
Name: "test-name",
|
Name: "test-name",
|
||||||
},
|
},
|
||||||
|
ScaleUpTriggers: []actionsv1alpha1.ScaleUpTrigger{
|
||||||
|
{
|
||||||
|
GitHubEvent: &actionsv1alpha1.GitHubEventScaleUpTriggerSpec{
|
||||||
|
WorkflowJob: &actionsv1alpha1.WorkflowJobSpec{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,6 +298,13 @@ func TestWebhookWorkflowJobWithSelfHostedLabel(t *testing.T) {
|
||||||
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
||||||
Name: "test-name",
|
Name: "test-name",
|
||||||
},
|
},
|
||||||
|
ScaleUpTriggers: []actionsv1alpha1.ScaleUpTrigger{
|
||||||
|
{
|
||||||
|
GitHubEvent: &actionsv1alpha1.GitHubEventScaleUpTriggerSpec{
|
||||||
|
WorkflowJob: &actionsv1alpha1.WorkflowJobSpec{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -316,6 +344,13 @@ func TestWebhookWorkflowJobWithSelfHostedLabel(t *testing.T) {
|
||||||
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
||||||
Name: "test-name",
|
Name: "test-name",
|
||||||
},
|
},
|
||||||
|
ScaleUpTriggers: []actionsv1alpha1.ScaleUpTrigger{
|
||||||
|
{
|
||||||
|
GitHubEvent: &actionsv1alpha1.GitHubEventScaleUpTriggerSpec{
|
||||||
|
WorkflowJob: &actionsv1alpha1.WorkflowJobSpec{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,6 +391,13 @@ func TestWebhookWorkflowJobWithSelfHostedLabel(t *testing.T) {
|
||||||
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
ScaleTargetRef: actionsv1alpha1.ScaleTargetRef{
|
||||||
Name: "test-name",
|
Name: "test-name",
|
||||||
},
|
},
|
||||||
|
ScaleUpTriggers: []actionsv1alpha1.ScaleUpTrigger{
|
||||||
|
{
|
||||||
|
GitHubEvent: &actionsv1alpha1.GitHubEventScaleUpTriggerSpec{
|
||||||
|
WorkflowJob: &actionsv1alpha1.WorkflowJobSpec{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1228,9 +1228,11 @@ var _ = Context("INTEGRATION: Inside of a new namespace", func() {
|
||||||
ScaleDownDelaySecondsAfterScaleUp: intPtr(1),
|
ScaleDownDelaySecondsAfterScaleUp: intPtr(1),
|
||||||
ScaleUpTriggers: []actionsv1alpha1.ScaleUpTrigger{
|
ScaleUpTriggers: []actionsv1alpha1.ScaleUpTrigger{
|
||||||
{
|
{
|
||||||
GitHubEvent: &actionsv1alpha1.GitHubEventScaleUpTriggerSpec{},
|
GitHubEvent: &actionsv1alpha1.GitHubEventScaleUpTriggerSpec{
|
||||||
Amount: 1,
|
WorkflowJob: &actionsv1alpha1.WorkflowJobSpec{},
|
||||||
Duration: metav1.Duration{Duration: time.Minute},
|
},
|
||||||
|
Amount: 1,
|
||||||
|
Duration: metav1.Duration{Duration: time.Minute},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -1310,9 +1312,11 @@ var _ = Context("INTEGRATION: Inside of a new namespace", func() {
|
||||||
ScaleDownDelaySecondsAfterScaleUp: intPtr(1),
|
ScaleDownDelaySecondsAfterScaleUp: intPtr(1),
|
||||||
ScaleUpTriggers: []actionsv1alpha1.ScaleUpTrigger{
|
ScaleUpTriggers: []actionsv1alpha1.ScaleUpTrigger{
|
||||||
{
|
{
|
||||||
GitHubEvent: &actionsv1alpha1.GitHubEventScaleUpTriggerSpec{},
|
GitHubEvent: &actionsv1alpha1.GitHubEventScaleUpTriggerSpec{
|
||||||
Amount: 1,
|
WorkflowJob: &actionsv1alpha1.WorkflowJobSpec{},
|
||||||
Duration: metav1.Duration{Duration: time.Minute},
|
},
|
||||||
|
Amount: 1,
|
||||||
|
Duration: metav1.Duration{Duration: time.Minute},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue