@@ -362,21 +362,9 @@ func (r *Reconciler) createOrUpdateMachineSetsAndSyncMachineDeploymentRevision(c
362362 // Note: no need to check for diff doesn't exist, all the diff have been computed right above.
363363 diff := machineSetsDiff [ms .Name ]
364364
365- // Add to the log kv pairs providing context and details about changes in this MachineSet (reason, diff),
366- // and also add the overview of all the MachineSets computed above.
367- // Note: Those values should not be added to the context to prevent propagation to other func.
368- statusToLogKeyAndValues := []any {
369- "reason" , diff .Reason ,
370- "diff" , diff .OtherChanges ,
371- "machinesets" , machineSetsSummary ,
372- }
373- if len (p .acknowledgedMachineNames ) > 0 {
374- statusToLogKeyAndValues = append (statusToLogKeyAndValues , "acknowledgedMachines" , sortAndJoin (p .acknowledgedMachineNames ))
375- }
376- if len (p .updatingMachineNames ) > 0 {
377- statusToLogKeyAndValues = append (statusToLogKeyAndValues , "updatingMachines" , sortAndJoin (p .updatingMachineNames ))
378- }
379- log := log .WithValues (statusToLogKeyAndValues ... )
365+ // Add to the log kv pairs providing the overview of all the MachineSets computed above.
366+ // Note: This value should not be added to the context to prevent propagation to other func.
367+ log := log .WithValues ("machineSets" , machineSetsSummary )
380368
381369 if diff .OriginalMS == nil {
382370 // Create the MachineSet.
@@ -388,7 +376,7 @@ func (r *Reconciler) createOrUpdateMachineSetsAndSyncMachineDeploymentRevision(c
388376 log .Info (fmt .Sprintf ("MachineSets need rollout: %s" , strings .Join (machineSetNames (p .oldMSs ), ", " )), "reason" , p .createReason )
389377 }
390378 log .Info (fmt .Sprintf ("MachineSet %s created, it is now the current MachineSet" , ms .Name ))
391- if ptr . Deref ( ms . Spec . Replicas , 0 ) > 0 {
379+ if diff . DesiredReplicas > 0 {
392380 log .Info (fmt .Sprintf ("Scaled up current MachineSet %s from 0 to %d replicas (+%[2]d)" , ms .Name , diff .DesiredReplicas ))
393381 }
394382 r .recorder .Eventf (p .md , corev1 .EventTypeNormal , "SuccessfulCreate" , "Created MachineSet %s with %d replicas" , klog .KObj (ms ), diff .DesiredReplicas )
@@ -403,6 +391,20 @@ func (r *Reconciler) createOrUpdateMachineSetsAndSyncMachineDeploymentRevision(c
403391 continue
404392 }
405393
394+ // Add to the log kv pairs providing context and details about changes in this MachineSet (reason, diff)
395+ // Note: Those values should not be added to the context to prevent propagation to other func.
396+ statusToLogKeyAndValues := []any {
397+ "reason" , diff .Reason ,
398+ "diff" , diff .OtherChanges ,
399+ }
400+ if len (p .acknowledgedMachineNames ) > 0 {
401+ statusToLogKeyAndValues = append (statusToLogKeyAndValues , "acknowledgedMachines" , sortAndJoin (p .acknowledgedMachineNames ))
402+ }
403+ if len (p .updatingMachineNames ) > 0 {
404+ statusToLogKeyAndValues = append (statusToLogKeyAndValues , "updatingMachines" , sortAndJoin (p .updatingMachineNames ))
405+ }
406+ log = log .WithValues (statusToLogKeyAndValues ... )
407+
406408 err := ssa .Patch (ctx , r .Client , machineDeploymentManagerName , ms , ssa.WithCachingProxy {Cache : r .ssaCache , Original : diff .OriginalMS })
407409 if err != nil {
408410 // Note: If we are Applying a MachineSet with UID set and the MachineSet does not exist anymore, the
0 commit comments