@@ -62,9 +62,16 @@ func (dc *controller) rollback(d *v1alpha1.MachineDeployment, isList []*v1alpha1
6262 glog .V (4 ).Infof ("Found machine set %q with desired revision %d" , is .Name , v )
6363
6464 // Remove PreferNoSchedule taints from nodes which were backing the machineSet
65- err = dc .removeTaintNodesBackingMachineSets (is )
65+ err = dc .removeTaintNodesBackingMachineSet (
66+ is ,
67+ & v1.Taint {
68+ Key : PreferNoScheduleKey ,
69+ Value : "True" ,
70+ Effect : "PreferNoSchedule" ,
71+ },
72+ )
6673 if err != nil {
67- glog .Warningf ("Failed to remove taints %s off nodes. Error: %s" , PreferNoSchedule , err )
74+ glog .Warningf ("Failed to remove taints %s off nodes. Error: %s" , PreferNoScheduleKey , err )
6875 }
6976
7077 // rollback by copying podTemplate.Spec from the machine set
@@ -130,16 +137,16 @@ func (dc *controller) updateMachineDeploymentAndClearRollbackTo(d *v1alpha1.Mach
130137 return err
131138}
132139
133- // removeTaintNodesBackingMachineSets removes taints from all nodes backing the machineSets
134- func (dc * controller ) removeTaintNodesBackingMachineSets (machineSet * v1alpha1.MachineSet ) error {
140+ // removeTaintNodesBackingMachineSet removes taints from all nodes backing the machineSets
141+ func (dc * controller ) removeTaintNodesBackingMachineSet (machineSet * v1alpha1.MachineSet , taint * v1. Taint ) error {
135142
136- if machineSet .Annotations [PreferNoSchedule ] == "" {
143+ if _ , exists := machineSet .Annotations [taint . Key ]; ! exists {
137144 // No taint exists
138- glog .Warningf ("No taint exits on machineSet: %s. Hence not removing." , machineSet .Name )
145+ glog .Warningf ("No taint exists on machineSet: %s. Hence not removing." , machineSet .Name )
139146 return nil
140147 }
141148
142- glog .V (2 ).Infof ("Trying to untaint MachineSet object %q with %s to enable scheduling of pods" , machineSet .Name , PreferNoSchedule )
149+ glog .V (2 ).Infof ("Trying to untaint MachineSet object %q with %s to enable scheduling of pods" , machineSet .Name , taint . Key )
143150 selector , err := metav1 .LabelSelectorAsSelector (machineSet .Spec .Selector )
144151 if err != nil {
145152 return err
@@ -159,12 +166,6 @@ func (dc *controller) removeTaintNodesBackingMachineSets(machineSet *v1alpha1.Ma
159166 return err
160167 }
161168
162- taints := v1.Taint {
163- Key : PreferNoSchedule ,
164- Value : "True" ,
165- Effect : "PreferNoSchedule" ,
166- }
167-
168169 // Iterate through all machines and remove the PreferNoSchedule taint
169170 // to avoid scheduling on older machines
170171 for _ , machine := range filteredMachines {
@@ -179,7 +180,7 @@ func (dc *controller) removeTaintNodesBackingMachineSets(machineSet *v1alpha1.Ma
179180 dc .targetCoreClient ,
180181 machine .Status .Node ,
181182 node ,
182- & taints ,
183+ taint ,
183184 )
184185 if err != nil {
185186 glog .Warningf ("Node taint removal failed for node: %s, Error: %s" , machine .Status .Node , err )
@@ -202,7 +203,7 @@ func (dc *controller) removeTaintNodesBackingMachineSets(machineSet *v1alpha1.Ma
202203 }
203204
204205 msCopy := machineSet .DeepCopy ()
205- delete (msCopy .Annotations , PreferNoSchedule )
206+ delete (msCopy .Annotations , taint . Key )
206207
207208 machineSet , err = dc .controlMachineClient .MachineSets (msCopy .Namespace ).Update (msCopy )
208209
@@ -219,7 +220,7 @@ func (dc *controller) removeTaintNodesBackingMachineSets(machineSet *v1alpha1.Ma
219220 // Break out of loop when update succeeds
220221 break
221222 }
222- glog .V (2 ).Infof ("Removed taint %s from MachineSet object %q" , PreferNoSchedule , machineSet .Name )
223+ glog .V (2 ).Infof ("Removed taint %s from MachineSet object %q" , taint . Key , machineSet .Name )
223224
224225 return nil
225226}
0 commit comments