@@ -649,15 +649,32 @@ 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 )
656- } else {
657- if err := dn .nodeWriter .SetDegraded (err ); err != nil {
658- return err
659- }
659+ return dn .nodeWriter .SetUnreconcilable (err )
660+ }
661+ return dn .updateDegradedState (err )
662+ }
663+
664+ // `updateDegradedState` calls `SetDegraded` to set the node's state annotation value to "Degraded"
665+ // and populate the associated reason annotation. It then sets the degrade condition in the MCN.
666+ func (dn * Daemon ) updateDegradedState (err error ) error {
667+ // Set node state annotation to "Degraded"
668+ if setErr := dn .nodeWriter .SetDegraded (err ); setErr != nil {
669+ return setErr
670+ }
671+ // Get MCP associated with node
672+ pool , poolErr := helpers .GetPrimaryPoolNameForMCN (dn .mcpLister , dn .node )
673+ if poolErr != nil {
674+ return poolErr
660675 }
676+ // Set the node's MCN condition to "Degraded"
677+ dn .reportMachineNodeDegradeStatus (err , pool )
661678 return nil
662679}
663680
@@ -2419,7 +2436,7 @@ func (dn *Daemon) runOnceFromMachineConfig(machineConfig mcfgv1.MachineConfig, c
24192436 // NOTE: This case expects a cluster to exists already.
24202437 ufc , err := dn .prepUpdateFromCluster ()
24212438 if err != nil {
2422- if err := dn .nodeWriter . SetDegraded (err ); err != nil {
2439+ if err := dn .updateDegradedState (err ); err != nil {
24232440 return err
24242441 }
24252442 return err
@@ -2429,7 +2446,7 @@ func (dn *Daemon) runOnceFromMachineConfig(machineConfig mcfgv1.MachineConfig, c
24292446 }
24302447 // At this point we have verified we need to update
24312448 if err = dn .triggerUpdateWithMachineConfig (ufc .currentConfig , & machineConfig , false ); err != nil {
2432- dn .nodeWriter . SetDegraded (err )
2449+ dn .updateDegradedState (err )
24332450 return err
24342451 }
24352452 return nil
0 commit comments