Skip to content

Commit f6914b9

Browse files
daemon: update 'SetDegrade' flow to include updating the degrade condition in the MCN
1 parent 4fd1c79 commit f6914b9

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

pkg/controller/node/status.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ func (ctrl *Controller) calculateStatus(fg featuregates.FeatureGate, mcs []*mcfg
139139
// populate the degradedReasons from the MachineConfigNodeNodeDegraded condition
140140
if mcfgv1.StateProgress(cond.Type) == mcfgv1.MachineConfigNodeNodeDegraded && cond.Status == metav1.ConditionTrue {
141141
degradedMachines = append(degradedMachines, ourNode)
142+
// Degraded nodes are also unavailable since they are not in a "Done" state
143+
// and cannot be used for further updates (see IsUnavailableForUpdate)
144+
unavailableMachines = append(unavailableMachines, ourNode)
142145
degradedReasons = append(degradedReasons, fmt.Sprintf("Node %s is reporting: %q", ourNode.Name, cond.Message))
143146
break
144147
}

pkg/daemon/daemon.go

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
640644
func (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

Comments
 (0)