@@ -2,6 +2,7 @@ package job
2
2
3
3
import (
4
4
"os"
5
+ "sort"
5
6
"strconv"
6
7
7
8
"github.com/rancher/system-upgrade-controller/pkg/apis/condition"
94
95
func New (plan * upgradeapiv1.Plan , node * corev1.Node , controllerName string ) * batchv1.Job {
95
96
hostPathDirectory := corev1 .HostPathDirectory
96
97
labelPlanName := upgradeapi .LabelPlanName (plan .Name )
98
+ nodeHostname := upgradenode .Hostname (node )
97
99
job := & batchv1.Job {
98
100
ObjectMeta : metav1.ObjectMeta {
99
101
Name : name .SafeConcatName ("apply" , plan .Name , "on" , node .Name , "with" , plan .Status .LatestHash ),
@@ -136,7 +138,7 @@ func New(plan *upgradeapiv1.Plan, node *corev1.Node, controllerName string) *bat
136
138
Key : corev1 .LabelHostname ,
137
139
Operator : corev1 .NodeSelectorOpIn ,
138
140
Values : []string {
139
- upgradenode . Hostname ( node ) ,
141
+ nodeHostname ,
140
142
},
141
143
}},
142
144
}},
@@ -184,8 +186,16 @@ func New(plan *upgradeapiv1.Plan, node *corev1.Node, controllerName string) *bat
184
186
}},
185
187
},
186
188
},
189
+ Completions : new (int32 ),
190
+ Parallelism : new (int32 ),
187
191
},
188
192
}
193
+
194
+ * job .Spec .Completions = 1
195
+ if i := sort .SearchStrings (plan .Status .Applying , nodeHostname ); i < len (plan .Status .Applying ) && plan .Status .Applying [i ] == nodeHostname {
196
+ * job .Spec .Parallelism = 1
197
+ }
198
+
189
199
podTemplate := & job .Spec .Template
190
200
// setup secrets volumes
191
201
for _ , secret := range plan .Spec .Secrets {
0 commit comments