mirror of https://github.com/k3s-io/k3s
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 ```pull/8/head
commit
332da0a943
|
@ -1109,6 +1109,10 @@ type Kubelet struct {
|
|||
// handlers called during the tryUpdateNodeStatus cycle
|
||||
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.
|
||||
// the list of handlers to call during pod admission.
|
||||
admitHandlers lifecycle.PodAdmitHandlers
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
"net"
|
||||
goruntime "runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"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.
|
||||
func (kl *Kubelet) recordNodeSchedulableEvent(node *v1.Node) {
|
||||
oldNodeUnschedulableLock.Lock()
|
||||
defer oldNodeUnschedulableLock.Unlock()
|
||||
if oldNodeUnschedulable != node.Spec.Unschedulable {
|
||||
kl.lastNodeUnschedulableLock.Lock()
|
||||
defer kl.lastNodeUnschedulableLock.Unlock()
|
||||
if kl.lastNodeUnschedulable != node.Spec.Unschedulable {
|
||||
if node.Spec.Unschedulable {
|
||||
kl.recordNodeStatusEvent(v1.EventTypeNormal, events.NodeNotSchedulable)
|
||||
} else {
|
||||
kl.recordNodeStatusEvent(v1.EventTypeNormal, events.NodeSchedulable)
|
||||
}
|
||||
oldNodeUnschedulable = node.Spec.Unschedulable
|
||||
kl.lastNodeUnschedulable = node.Spec.Unschedulable
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue