mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Merge pull request #64491 from hzxuzhonghu/kubelet-node-schedule-event-record
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. move oldNodeUnschedulable pkg var to kubelet struct **What this PR does / why we need it**: move oldNodeUnschedulable pkg var to kubelet struct **Release note**: ```release-note NONE ```
This commit is contained in:
commit
332da0a943
@ -1109,6 +1109,10 @@ type Kubelet struct {
|
|||||||
// handlers called during the tryUpdateNodeStatus cycle
|
// handlers called during the tryUpdateNodeStatus cycle
|
||||||
setNodeStatusFuncs []func(*v1.Node) error
|
setNodeStatusFuncs []func(*v1.Node) error
|
||||||
|
|
||||||
|
lastNodeUnschedulableLock sync.Mutex
|
||||||
|
// maintains Node.Spec.Unschedulable value from previous run of tryUpdateNodeStatus()
|
||||||
|
lastNodeUnschedulable bool
|
||||||
|
|
||||||
// TODO: think about moving this to be centralized in PodWorkers in follow-on.
|
// TODO: think about moving this to be centralized in PodWorkers in follow-on.
|
||||||
// the list of handlers to call during pod admission.
|
// the list of handlers to call during pod admission.
|
||||||
admitHandlers lifecycle.PodAdmitHandlers
|
admitHandlers lifecycle.PodAdmitHandlers
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
goruntime "runtime"
|
goruntime "runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
@ -1073,24 +1072,17 @@ func (kl *Kubelet) setNodeOODCondition(node *v1.Node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maintains Node.Spec.Unschedulable value from previous run of tryUpdateNodeStatus()
|
|
||||||
// TODO: why is this a package var?
|
|
||||||
var (
|
|
||||||
oldNodeUnschedulable bool
|
|
||||||
oldNodeUnschedulableLock sync.Mutex
|
|
||||||
)
|
|
||||||
|
|
||||||
// record if node schedulable change.
|
// record if node schedulable change.
|
||||||
func (kl *Kubelet) recordNodeSchedulableEvent(node *v1.Node) {
|
func (kl *Kubelet) recordNodeSchedulableEvent(node *v1.Node) {
|
||||||
oldNodeUnschedulableLock.Lock()
|
kl.lastNodeUnschedulableLock.Lock()
|
||||||
defer oldNodeUnschedulableLock.Unlock()
|
defer kl.lastNodeUnschedulableLock.Unlock()
|
||||||
if oldNodeUnschedulable != node.Spec.Unschedulable {
|
if kl.lastNodeUnschedulable != node.Spec.Unschedulable {
|
||||||
if node.Spec.Unschedulable {
|
if node.Spec.Unschedulable {
|
||||||
kl.recordNodeStatusEvent(v1.EventTypeNormal, events.NodeNotSchedulable)
|
kl.recordNodeStatusEvent(v1.EventTypeNormal, events.NodeNotSchedulable)
|
||||||
} else {
|
} else {
|
||||||
kl.recordNodeStatusEvent(v1.EventTypeNormal, events.NodeSchedulable)
|
kl.recordNodeStatusEvent(v1.EventTypeNormal, events.NodeSchedulable)
|
||||||
}
|
}
|
||||||
oldNodeUnschedulable = node.Spec.Unschedulable
|
kl.lastNodeUnschedulable = node.Spec.Unschedulable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user