Skip to content

Commit 3239c79

Browse files
authored
fix: set BackoffLimit to zero for starter and stopper jobs to prevent excessive pod creation (#659)
* fix: set BackoffLimit to zero for starter job to prevent excessive pod creation * test: set BackoffLimit to 0 for starter and stopper job tests
1 parent d0a08ef commit 3239c79

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

pkg/resources/jobs/starter.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ func NewStarterJob(k6 *v1alpha1.TestRun, hostname []string) *batchv1.Job {
6262
resourceRequirements = k6.GetSpec().Starter.Resources
6363
}
6464

65+
var zero32 int32
66+
6567
return &batchv1.Job{
6668
ObjectMeta: metav1.ObjectMeta{
6769
Name: fmt.Sprintf("%s-starter", k6.NamespacedName().Name),
@@ -70,6 +72,7 @@ func NewStarterJob(k6 *v1alpha1.TestRun, hostname []string) *batchv1.Job {
7072
Annotations: starterAnnotations,
7173
},
7274
Spec: batchv1.JobSpec{
75+
BackoffLimit: &zero32,
7376
Template: corev1.PodTemplateSpec{
7477
ObjectMeta: metav1.ObjectMeta{
7578
Labels: starterLabels,

pkg/resources/jobs/starter_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
func TestNewStarterJob(t *testing.T) {
1616

1717
automountServiceAccountToken := true
18+
zero := int32(0)
1819

1920
expectedOutcome := &batchv1.Job{
2021
ObjectMeta: metav1.ObjectMeta{
@@ -30,6 +31,7 @@ func TestNewStarterJob(t *testing.T) {
3031
},
3132
},
3233
Spec: batchv1.JobSpec{
34+
BackoffLimit: &zero,
3335
Template: corev1.PodTemplateSpec{
3436
ObjectMeta: metav1.ObjectMeta{
3537
Labels: map[string]string{
@@ -106,6 +108,7 @@ func TestNewStarterJob(t *testing.T) {
106108
func TestNewStarterJobIstio(t *testing.T) {
107109

108110
automountServiceAccountToken := true
111+
zero := int32(0)
109112

110113
expectedOutcome := &batchv1.Job{
111114
ObjectMeta: metav1.ObjectMeta{
@@ -121,6 +124,7 @@ func TestNewStarterJobIstio(t *testing.T) {
121124
},
122125
},
123126
Spec: batchv1.JobSpec{
127+
BackoffLimit: &zero,
124128
Template: corev1.PodTemplateSpec{
125129
ObjectMeta: metav1.ObjectMeta{
126130
Labels: map[string]string{

pkg/resources/jobs/stopper_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
func TestNewStopperJob(t *testing.T) {
1515
automountServiceAccountToken := true
16+
zero := int32(0)
1617

1718
expectedOutcome := &batchv1.Job{
1819
ObjectMeta: metav1.ObjectMeta{
@@ -28,6 +29,7 @@ func TestNewStopperJob(t *testing.T) {
2829
},
2930
},
3031
Spec: batchv1.JobSpec{
32+
BackoffLimit: &zero,
3133
Template: corev1.PodTemplateSpec{
3234
ObjectMeta: metav1.ObjectMeta{
3335
Labels: map[string]string{
@@ -93,6 +95,7 @@ func TestNewStopperJob(t *testing.T) {
9395

9496
func TestNewStopJobIstio(t *testing.T) {
9597
automountServiceAccountToken := true
98+
zero := int32(0)
9699

97100
expectedOutcome := &batchv1.Job{
98101
ObjectMeta: metav1.ObjectMeta{
@@ -108,6 +111,7 @@ func TestNewStopJobIstio(t *testing.T) {
108111
},
109112
},
110113
Spec: batchv1.JobSpec{
114+
BackoffLimit: &zero,
111115
Template: corev1.PodTemplateSpec{
112116
ObjectMeta: metav1.ObjectMeta{
113117
Labels: map[string]string{

0 commit comments

Comments
 (0)