Skip to content

Commit eb2fff6

Browse files
author
Sedef
committed
Address comments
1 parent a2083cf commit eb2fff6

File tree

3 files changed

+15
-32
lines changed

3 files changed

+15
-32
lines changed

api/v1alpha3/condition_consts.go

-20
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ const (
126126
)
127127

128128
// Conditions and condition Reasons for the Machine's Node object
129-
130129
const (
131130
// MachineNodeHealthyCondition provides info about the operational state of the Kubernetes node hosted on the machine by summarizing node conditions.
132131
// If the conditions defined in a Kubernetes node (i.e., NodeReady, NodeMemoryPressure, NodeDiskPressure, NodePIDPressure, and NodeNetworkUnavailable) are in a healthy state, it will be set to True.
@@ -143,22 +142,3 @@ const (
143142
// NodeConditionsFailedReason (Severity=Warning) documents a node is not in a healthy state due to the failed state of at least 1 Kubelet condition.
144143
NodeConditionsFailedReason = "NodeConditionsFailed"
145144
)
146-
147-
// Common Pod-related Condition Reasons used by Pod-related Conditions.
148-
const (
149-
// PodProvisioningReason (Severity=Info) documents a pod waiting to be provisioned i.e., Pod is in "Pending" phase and
150-
// PodScheduled and Initialized conditions are not set to True yet.
151-
PodProvisioningReason = "PodProvisioning"
152-
153-
// PodProvisioningReason (Severity=Warning) documents a pod failed during provisioning i.e., Pod is in "Pending" phase and
154-
// PodScheduled and Initialized conditions are set to True,
155-
// but ContainersReady or Ready condition is false (i.e., at least one of the containers are in waiting state(e.g CrashLoopbackOff, ImagePullBackOff)
156-
PodProvisioningFailedReason = "PodProvisioningFailed"
157-
158-
// PodMissingReason (Severity=Warning) documents a pod does not exist.
159-
PodMissingReason = "PodMissing"
160-
161-
// PodFailedReason (Severity=Error) documents a pod's at least one container has terminated in a failure
162-
// and hence Pod is in "Failed" phase.
163-
PodFailedReason = "PodFailed"
164-
)

controllers/machine_controller_noderef.go renamed to controllers/machine_controller_node.go

+15-12
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,12 @@ func (r *MachineReconciler) reconcileNode(ctx context.Context, cluster *clusterv
6767
// If Status.NodeRef is not set before, node still can be in the provisioning state.
6868
if machine.Status.NodeRef != nil {
6969
conditions.MarkFalse(machine, clusterv1.MachineNodeHealthyCondition, clusterv1.NodeNotFoundReason, clusterv1.ConditionSeverityError, "")
70-
return errors.Wrapf(&capierrors.RequeueAfterError{RequeueAfter: 20 * time.Second},
71-
"failed to find the Node owned by Machine %q in namespace %q", machine.Name, machine.Namespace)
7270
}
73-
74-
logger.Error(err, "Failed to assign NodeRef")
75-
r.recorder.Event(machine, apicorev1.EventTypeWarning, "FailedSetNodeRef", err.Error())
7671
return errors.Wrapf(&capierrors.RequeueAfterError{RequeueAfter: 20 * time.Second},
7772
"cannot assign NodeRef to Machine %q in namespace %q, no matching Node", machine.Name, machine.Namespace)
7873
}
79-
// This may be a transient client error and may not mean there is no matching Node.
74+
logger.Error(err, "Failed to assign NodeRef")
75+
r.recorder.Event(machine, apicorev1.EventTypeWarning, "FailedSetNodeRef", err.Error())
8076
return err
8177
}
8278

@@ -104,14 +100,21 @@ func (r *MachineReconciler) reconcileNode(ctx context.Context, cluster *clusterv
104100
return nil
105101
}
106102

107-
// Return true if all Node Conditions are false other than "Ready" condition.
108-
// "Ready" being false does not mean there is a problem with the Node, may be missing CNI.
103+
// checkNodeConditions checks if a Node is healthy and does not have any semantically negative Conditions.
104+
// Returns true if NodeMemoryPressure, NodeDiskPressure, or NodePIDPressure Conditions are false or Ready Condition is true.
109105
func checkNodeConditions(node *apicorev1.Node) bool {
110106
for _, condition := range node.Status.Conditions {
111-
if condition.Type != apicorev1.NodeReady {
112-
if condition.Status == apicorev1.ConditionTrue {
113-
return false
114-
}
107+
if condition.Type == apicorev1.NodeMemoryPressure && condition.Status == apicorev1.ConditionTrue {
108+
return false
109+
}
110+
if condition.Type == apicorev1.NodeDiskPressure && condition.Status == apicorev1.ConditionTrue {
111+
return false
112+
}
113+
if condition.Type == apicorev1.NodePIDPressure && condition.Status == apicorev1.ConditionTrue {
114+
return false
115+
}
116+
if condition.Type == apicorev1.NodeReady && condition.Status == apicorev1.ConditionFalse {
117+
return false
115118
}
116119
}
117120
return true

0 commit comments

Comments
 (0)