mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
kubelet: fix node ready condition logic
Fixes #8585 Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
This commit is contained in:
parent
2f503c57a5
commit
fefc65164a
@ -1788,9 +1788,10 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
currentTime := util.Now()
|
currentTime := util.Now()
|
||||||
var newCondition api.NodeCondition
|
var newNodeReadyCondition api.NodeCondition
|
||||||
|
var oldNodeReadyConditionStatus api.ConditionStatus
|
||||||
if containerRuntimeUp && networkConfigured {
|
if containerRuntimeUp && networkConfigured {
|
||||||
newCondition = api.NodeCondition{
|
newNodeReadyCondition = api.NodeCondition{
|
||||||
Type: api.NodeReady,
|
Type: api.NodeReady,
|
||||||
Status: api.ConditionTrue,
|
Status: api.ConditionTrue,
|
||||||
Reason: "kubelet is posting ready status",
|
Reason: "kubelet is posting ready status",
|
||||||
@ -1804,7 +1805,7 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
|
|||||||
if !networkConfigured {
|
if !networkConfigured {
|
||||||
reasons = append(reasons, "network not configured correctly")
|
reasons = append(reasons, "network not configured correctly")
|
||||||
}
|
}
|
||||||
newCondition = api.NodeCondition{
|
newNodeReadyCondition = api.NodeCondition{
|
||||||
Type: api.NodeReady,
|
Type: api.NodeReady,
|
||||||
Status: api.ConditionFalse,
|
Status: api.ConditionFalse,
|
||||||
Reason: strings.Join(reasons, ","),
|
Reason: strings.Join(reasons, ","),
|
||||||
@ -1815,20 +1816,27 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
|
|||||||
updated := false
|
updated := false
|
||||||
for i := range node.Status.Conditions {
|
for i := range node.Status.Conditions {
|
||||||
if node.Status.Conditions[i].Type == api.NodeReady {
|
if node.Status.Conditions[i].Type == api.NodeReady {
|
||||||
newCondition.LastTransitionTime = node.Status.Conditions[i].LastTransitionTime
|
oldNodeReadyConditionStatus = node.Status.Conditions[i].Status
|
||||||
if node.Status.Conditions[i].Status != api.ConditionTrue {
|
if oldNodeReadyConditionStatus == newNodeReadyCondition.Status {
|
||||||
kl.recordNodeStatusEvent("NodeReady")
|
newNodeReadyCondition.LastTransitionTime = node.Status.Conditions[i].LastTransitionTime
|
||||||
|
} else {
|
||||||
|
newNodeReadyCondition.LastTransitionTime = currentTime
|
||||||
}
|
}
|
||||||
node.Status.Conditions[i] = newCondition
|
node.Status.Conditions[i] = newNodeReadyCondition
|
||||||
updated = true
|
updated = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !updated {
|
if !updated {
|
||||||
newCondition.LastTransitionTime = currentTime
|
newNodeReadyCondition.LastTransitionTime = currentTime
|
||||||
node.Status.Conditions = append(node.Status.Conditions, newCondition)
|
node.Status.Conditions = append(node.Status.Conditions, newNodeReadyCondition)
|
||||||
kl.recordNodeStatusEvent("NodeReady")
|
}
|
||||||
|
if !updated || oldNodeReadyConditionStatus != newNodeReadyCondition.Status {
|
||||||
|
if newNodeReadyCondition.Status == api.ConditionTrue {
|
||||||
|
kl.recordNodeStatusEvent("NodeReady")
|
||||||
|
} else {
|
||||||
|
kl.recordNodeStatusEvent("NodeNotReady")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if oldNodeUnschedulable != node.Spec.Unschedulable {
|
if oldNodeUnschedulable != node.Spec.Unschedulable {
|
||||||
if node.Spec.Unschedulable {
|
if node.Spec.Unschedulable {
|
||||||
kl.recordNodeStatusEvent("NodeNotSchedulable")
|
kl.recordNodeStatusEvent("NodeNotSchedulable")
|
||||||
|
Loading…
Reference in New Issue
Block a user