@@ -649,15 +649,33 @@ type unreconcilableErr struct {
649649 error
650650}
651651
652+ // updateErrorState calls `SetUnreconcilable` to set the node's state annotation value to
653+ // "Unreconcilable" and the associated reason annotation if the provided error is an unreconcilable
654+ // error. Otherwise it calls `updateDegradedState` to set the node's state annotation value to
655+ // "Degraded," populate the associated reason annotation, and set the degrade condition in the MCN.
652656func (dn * Daemon ) updateErrorState (err error ) error {
653657 var uErr * unreconcilableErr
654658 if errors .As (err , & uErr ) {
655- dn .nodeWriter .SetUnreconcilable (err )
659+ return dn .nodeWriter .SetUnreconcilable (err )
656660 } else {
657- if err := dn .nodeWriter .SetDegraded (err ); err != nil {
658- return err
659- }
661+ return dn .updateDegradedState (err )
662+ }
663+ }
664+
665+ // `updateDegradedState` calls `SetDegraded` to set the node's state annotation value to "Degraded"
666+ // and populate the associated reason annotation. It then sets the degrade condition in the MCN.
667+ func (dn * Daemon ) updateDegradedState (err error ) error {
668+ // Set node state annotation to "Degraded"
669+ if setErr := dn .nodeWriter .SetDegraded (err ); setErr != nil {
670+ return setErr
671+ }
672+ // Get MCP associated with node
673+ pool , poolErr := helpers .GetPrimaryPoolNameForMCN (dn .mcpLister , dn .node )
674+ if poolErr != nil {
675+ return poolErr
660676 }
677+ // Set the node's MCN condition to "Degraded"
678+ dn .reportMachineNodeDegradeStatus (err , pool )
661679 return nil
662680}
663681
@@ -2419,7 +2437,7 @@ func (dn *Daemon) runOnceFromMachineConfig(machineConfig mcfgv1.MachineConfig, c
24192437 // NOTE: This case expects a cluster to exists already.
24202438 ufc , err := dn .prepUpdateFromCluster ()
24212439 if err != nil {
2422- if err := dn .nodeWriter . SetDegraded (err ); err != nil {
2440+ if err := dn .updateDegradedState (err ); err != nil {
24232441 return err
24242442 }
24252443 return err
@@ -2429,7 +2447,7 @@ func (dn *Daemon) runOnceFromMachineConfig(machineConfig mcfgv1.MachineConfig, c
24292447 }
24302448 // At this point we have verified we need to update
24312449 if err = dn .triggerUpdateWithMachineConfig (ufc .currentConfig , & machineConfig , false ); err != nil {
2432- dn .nodeWriter . SetDegraded (err )
2450+ dn .updateDegradedState (err )
24332451 return err
24342452 }
24352453 return nil
0 commit comments