mirror of https://github.com/k3s-io/k3s
move oldNodeUnschedulable pkg var to kubelet struct
parent
57b8fda91b
commit
9492cf368e
|
@ -1091,6 +1091,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"
|
||||
|
@ -1034,24 +1033,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