@@ -240,9 +240,9 @@ func (r *Reconciler) computeDesiredMachineSet(deployment *clusterv1.MachineDeplo
240
240
// Append a random string at the end of template hash. This is required to distinguish MachineSets that
241
241
// could be created with the same spec as a result of rolloutAfter. If not, computeDesiredMachineSet
242
242
// will end up updating the existing MachineSet instead of creating a new one.
243
- uniqueIdentifierLabelValue = fmt . Sprintf ( "%d-%s" , templateHash , apirand . String ( 5 ))
244
-
245
- name = computeNewMachineSetName ( deployment . Name + "- " , apirand . SafeEncodeString ( uniqueIdentifierLabelValue ) )
243
+ var randomSuffix string
244
+ name , randomSuffix = computeNewMachineSetName ( deployment . Name + "-" )
245
+ uniqueIdentifierLabelValue = fmt . Sprintf ( "%d-%s " , templateHash , randomSuffix )
246
246
247
247
// Add foregroundDeletion finalizer to MachineSet if the MachineDeployment has it.
248
248
if sets .New [string ](deployment .Finalizers ... ).Has (metav1 .FinalizerDeleteDependents ) {
@@ -366,11 +366,12 @@ const (
366
366
// the upstream SimpleNameGenerator.
367
367
// Note: We had to extract the logic as we want to use the MachineSet name suffix as
368
368
// unique identifier for the MachineSet.
369
- func computeNewMachineSetName (base , suffix string ) string {
369
+ func computeNewMachineSetName (base string ) ( string , string ) {
370
370
if len (base ) > maxGeneratedNameLength {
371
371
base = base [:maxGeneratedNameLength ]
372
372
}
373
- return fmt .Sprintf ("%s%s" , base , suffix )
373
+ r := apirand .String (randomLength )
374
+ return fmt .Sprintf ("%s%s" , base , r ), r
374
375
}
375
376
376
377
// scale scales proportionally in order to mitigate risk. Otherwise, scaling up can increase the size
0 commit comments