@@ -637,15 +637,32 @@ type unreconcilableErr struct {
637637 error
638638}
639639
640+ // updateErrorState calls `SetUnreconcilable` to set the node's state annotation value to
641+ // "Unreconcilable" and the associated reason annotation if the provided error is an unreconcilable
642+ // error. Otherwise it calls `updateDegradedState` to set the node's state annotation value to
643+ // "Degraded," populate the associated reason annotation, and set the degrade condition in the MCN.
640644func (dn * Daemon ) updateErrorState (err error ) error {
641645 var uErr * unreconcilableErr
642646 if errors .As (err , & uErr ) {
643- dn .nodeWriter .SetUnreconcilable (err )
644- } else {
645- if err := dn .nodeWriter .SetDegraded (err ); err != nil {
646- return err
647- }
647+ return dn .nodeWriter .SetUnreconcilable (err )
648+ }
649+ return dn .updateDegradedState (err )
650+ }
651+
652+ // `updateDegradedState` calls `SetDegraded` to set the node's state annotation value to "Degraded"
653+ // and populate the associated reason annotation. It then sets the degrade condition in the MCN.
654+ func (dn * Daemon ) updateDegradedState (err error ) error {
655+ // Set node state annotation to "Degraded"
656+ if setErr := dn .nodeWriter .SetDegraded (err ); setErr != nil {
657+ return setErr
658+ }
659+ // Get MCP associated with node
660+ pool , poolErr := helpers .GetPrimaryPoolNameForMCN (dn .mcpLister , dn .node )
661+ if poolErr != nil {
662+ return poolErr
648663 }
664+ // Set the node's MCN condition to "Degraded"
665+ dn .reportMachineNodeDegradeStatus (err , pool )
649666 return nil
650667}
651668
@@ -2390,7 +2407,7 @@ func (dn *Daemon) runOnceFromMachineConfig(machineConfig mcfgv1.MachineConfig, c
23902407 // NOTE: This case expects a cluster to exists already.
23912408 ufc , err := dn .prepUpdateFromCluster ()
23922409 if err != nil {
2393- if err := dn .nodeWriter . SetDegraded (err ); err != nil {
2410+ if err := dn .updateDegradedState (err ); err != nil {
23942411 return err
23952412 }
23962413 maybeReportOnMissingMC (err )
@@ -2401,7 +2418,7 @@ func (dn *Daemon) runOnceFromMachineConfig(machineConfig mcfgv1.MachineConfig, c
24012418 }
24022419 // At this point we have verified we need to update
24032420 if err = dn .triggerUpdateWithMachineConfig (ufc .currentConfig , & machineConfig , false ); err != nil {
2404- dn .nodeWriter . SetDegraded (err )
2421+ dn .updateDegradedState (err )
24052422 return err
24062423 }
24072424 return nil
0 commit comments