@@ -39,15 +39,8 @@ import (
3939
4040func (r * Reconciler ) updateStatus (ctx context.Context , s * scope ) (retErr error ) {
4141 // Get all Machines controlled by this MachineDeployment.
42- var machinesToBeRemediated , unhealthyMachines collections.Machines
43- var getMachinesSucceeded bool
44- if s .machines != nil {
45- getMachinesSucceeded = true
46- machinesToBeRemediated = s .machines .Filter (collections .IsUnhealthyAndOwnerRemediated )
47- unhealthyMachines = s .machines .Filter (collections .IsUnhealthy )
48- } else {
49- retErr = errors .Errorf ("failed to convert label selector to a map" )
50- }
42+ machinesToBeRemediated := s .machines .Filter (collections .IsUnhealthyAndOwnerRemediated )
43+ unhealthyMachines := s .machines .Filter (collections .IsUnhealthy )
5144
5245 // Copy label selector to its status counterpart in string format.
5346 // This is necessary for CRDs including scale subresources.
@@ -65,16 +58,16 @@ func (r *Reconciler) updateStatus(ctx context.Context, s *scope) (retErr error)
6558
6659 setAvailableCondition (ctx , s .machineDeployment , s .getAndAdoptMachineSetsForDeploymentSucceeded )
6760
68- setRollingOutCondition (ctx , s .machineDeployment , s .machines , getMachinesSucceeded )
61+ setRollingOutCondition (ctx , s .machineDeployment , s .machines )
6962 setScalingUpCondition (ctx , s .machineDeployment , s .machineSets , s .bootstrapTemplateNotFound , s .infrastructureTemplateNotFound , s .getAndAdoptMachineSetsForDeploymentSucceeded )
70- setScalingDownCondition (ctx , s .machineDeployment , s .machineSets , s .machines , s .getAndAdoptMachineSetsForDeploymentSucceeded , getMachinesSucceeded )
63+ setScalingDownCondition (ctx , s .machineDeployment , s .machineSets , s .machines , s .getAndAdoptMachineSetsForDeploymentSucceeded )
7164
72- setMachinesReadyCondition (ctx , s .machineDeployment , s .machines , getMachinesSucceeded )
73- setMachinesUpToDateCondition (ctx , s .machineDeployment , s .machines , getMachinesSucceeded )
65+ setMachinesReadyCondition (ctx , s .machineDeployment , s .machines )
66+ setMachinesUpToDateCondition (ctx , s .machineDeployment , s .machines )
7467
75- setRemediatingCondition (ctx , s .machineDeployment , machinesToBeRemediated , unhealthyMachines , getMachinesSucceeded )
68+ setRemediatingCondition (ctx , s .machineDeployment , machinesToBeRemediated , unhealthyMachines )
7669
77- setDeletingCondition (ctx , s .machineDeployment , s .machineSets , s .machines , s .getAndAdoptMachineSetsForDeploymentSucceeded , getMachinesSucceeded )
70+ setDeletingCondition (ctx , s .machineDeployment , s .machineSets , s .machines , s .getAndAdoptMachineSetsForDeploymentSucceeded )
7871
7972 return retErr
8073}
@@ -180,18 +173,7 @@ func setAvailableCondition(_ context.Context, machineDeployment *clusterv1.Machi
180173 })
181174}
182175
183- func setRollingOutCondition (_ context.Context , machineDeployment * clusterv1.MachineDeployment , machines collections.Machines , getMachinesSucceeded bool ) {
184- // If we got unexpected errors in listing the machines (this should never happen), surface them.
185- if ! getMachinesSucceeded {
186- conditions .Set (machineDeployment , metav1.Condition {
187- Type : clusterv1 .MachineDeploymentRollingOutCondition ,
188- Status : metav1 .ConditionUnknown ,
189- Reason : clusterv1 .MachineDeploymentRollingOutInternalErrorReason ,
190- Message : "Please check controller logs for errors" ,
191- })
192- return
193- }
194-
176+ func setRollingOutCondition (_ context.Context , machineDeployment * clusterv1.MachineDeployment , machines collections.Machines ) {
195177 // Count machines rolling out and collect reasons why a rollout is happening.
196178 // Note: The code below collects all the reasons for which at least a machine is rolling out; under normal circumstances
197179 // all the machines are rolling out for the same reasons, however, in case of changes to
@@ -304,7 +286,7 @@ func setScalingUpCondition(_ context.Context, machineDeployment *clusterv1.Machi
304286 })
305287}
306288
307- func setScalingDownCondition (_ context.Context , machineDeployment * clusterv1.MachineDeployment , machineSets []* clusterv1.MachineSet , machines collections.Machines , getAndAdoptMachineSetsForDeploymentSucceeded , getMachinesSucceeded bool ) {
289+ func setScalingDownCondition (_ context.Context , machineDeployment * clusterv1.MachineDeployment , machineSets []* clusterv1.MachineSet , machines collections.Machines , getAndAdoptMachineSetsForDeploymentSucceeded bool ) {
308290 // If we got unexpected errors in listing the machines sets (this should never happen), surface them.
309291 if ! getAndAdoptMachineSetsForDeploymentSucceeded {
310292 conditions .Set (machineDeployment , metav1.Condition {
@@ -336,11 +318,9 @@ func setScalingDownCondition(_ context.Context, machineDeployment *clusterv1.Mac
336318 // Scaling down.
337319 if currentReplicas > desiredReplicas {
338320 message := fmt .Sprintf ("Scaling down from %d to %d replicas" , currentReplicas , desiredReplicas )
339- if getMachinesSucceeded {
340- staleMessage := aggregateStaleMachines (machines )
341- if staleMessage != "" {
342- message += fmt .Sprintf ("\n * %s" , staleMessage )
343- }
321+ staleMessage := aggregateStaleMachines (machines )
322+ if staleMessage != "" {
323+ message += fmt .Sprintf ("\n * %s" , staleMessage )
344324 }
345325 conditions .Set (machineDeployment , metav1.Condition {
346326 Type : clusterv1 .MachineDeploymentScalingDownCondition ,
@@ -359,19 +339,8 @@ func setScalingDownCondition(_ context.Context, machineDeployment *clusterv1.Mac
359339 })
360340}
361341
362- func setMachinesReadyCondition (ctx context.Context , machineDeployment * clusterv1.MachineDeployment , machines collections.Machines , getMachinesSucceeded bool ) {
342+ func setMachinesReadyCondition (ctx context.Context , machineDeployment * clusterv1.MachineDeployment , machines collections.Machines ) {
363343 log := ctrl .LoggerFrom (ctx )
364- // If we got unexpected errors in listing the machines (this should never happen), surface them.
365- if ! getMachinesSucceeded {
366- conditions .Set (machineDeployment , metav1.Condition {
367- Type : clusterv1 .MachineDeploymentMachinesReadyCondition ,
368- Status : metav1 .ConditionUnknown ,
369- Reason : clusterv1 .MachineDeploymentMachinesReadyInternalErrorReason ,
370- Message : "Please check controller logs for errors" ,
371- })
372- return
373- }
374-
375344 if len (machines ) == 0 {
376345 conditions .Set (machineDeployment , metav1.Condition {
377346 Type : clusterv1 .MachineDeploymentMachinesReadyCondition ,
@@ -409,19 +378,8 @@ func setMachinesReadyCondition(ctx context.Context, machineDeployment *clusterv1
409378 conditions .Set (machineDeployment , * readyCondition )
410379}
411380
412- func setMachinesUpToDateCondition (ctx context.Context , machineDeployment * clusterv1.MachineDeployment , machines collections.Machines , getMachinesSucceeded bool ) {
381+ func setMachinesUpToDateCondition (ctx context.Context , machineDeployment * clusterv1.MachineDeployment , machines collections.Machines ) {
413382 log := ctrl .LoggerFrom (ctx )
414- // If we got unexpected errors in listing the machines (this should never happen), surface them.
415- if ! getMachinesSucceeded {
416- conditions .Set (machineDeployment , metav1.Condition {
417- Type : clusterv1 .MachineDeploymentMachinesUpToDateCondition ,
418- Status : metav1 .ConditionUnknown ,
419- Reason : clusterv1 .MachineDeploymentMachinesUpToDateInternalErrorReason ,
420- Message : "Please check controller logs for errors" ,
421- })
422- return
423- }
424-
425383 // Only consider Machines that have an UpToDate condition or are older than 10s.
426384 // This is done to ensure the MachinesUpToDate condition doesn't flicker after a new Machine is created,
427385 // because it can take a bit until the UpToDate condition is set on a new Machine.
@@ -466,17 +424,7 @@ func setMachinesUpToDateCondition(ctx context.Context, machineDeployment *cluste
466424 conditions .Set (machineDeployment , * upToDateCondition )
467425}
468426
469- func setRemediatingCondition (ctx context.Context , machineDeployment * clusterv1.MachineDeployment , machinesToBeRemediated , unhealthyMachines collections.Machines , getMachinesSucceeded bool ) {
470- if ! getMachinesSucceeded {
471- conditions .Set (machineDeployment , metav1.Condition {
472- Type : clusterv1 .MachineDeploymentRemediatingCondition ,
473- Status : metav1 .ConditionUnknown ,
474- Reason : clusterv1 .MachineDeploymentRemediatingInternalErrorReason ,
475- Message : "Please check controller logs for errors" ,
476- })
477- return
478- }
479-
427+ func setRemediatingCondition (ctx context.Context , machineDeployment * clusterv1.MachineDeployment , machinesToBeRemediated , unhealthyMachines collections.Machines ) {
480428 if len (machinesToBeRemediated ) == 0 {
481429 message := aggregateUnhealthyMachines (unhealthyMachines )
482430 conditions .Set (machineDeployment , metav1.Condition {
@@ -515,9 +463,9 @@ func setRemediatingCondition(ctx context.Context, machineDeployment *clusterv1.M
515463 })
516464}
517465
518- func setDeletingCondition (_ context.Context , machineDeployment * clusterv1.MachineDeployment , machineSets []* clusterv1.MachineSet , machines collections.Machines , getAndAdoptMachineSetsForDeploymentSucceeded , getMachinesSucceeded bool ) {
466+ func setDeletingCondition (_ context.Context , machineDeployment * clusterv1.MachineDeployment , machineSets []* clusterv1.MachineSet , machines collections.Machines , getAndAdoptMachineSetsForDeploymentSucceeded bool ) {
519467 // If we got unexpected errors in listing the machines sets or machines (this should never happen), surface them.
520- if ! getAndAdoptMachineSetsForDeploymentSucceeded || ! getMachinesSucceeded {
468+ if ! getAndAdoptMachineSetsForDeploymentSucceeded {
521469 conditions .Set (machineDeployment , metav1.Condition {
522470 Type : clusterv1 .MachineDeploymentDeletingCondition ,
523471 Status : metav1 .ConditionUnknown ,
0 commit comments