mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Merge pull request #49870 from k82cn/nc_rename_zone_tainer
Automatic merge from submit-queue (batch tested with PRs 49870, 49416, 49872, 49892, 49908) Renamed zoneNotReadyOrUnreachableTainer to zoneNoExecuteTainer. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: partially fixes #42001 **Release note**: ```release-note None ```
This commit is contained in:
commit
455d85a984
@ -152,8 +152,8 @@ type NodeController struct {
|
|||||||
// workers that evicts pods from unresponsive nodes.
|
// workers that evicts pods from unresponsive nodes.
|
||||||
zonePodEvictor map[string]*RateLimitedTimedQueue
|
zonePodEvictor map[string]*RateLimitedTimedQueue
|
||||||
// workers that are responsible for tainting nodes.
|
// workers that are responsible for tainting nodes.
|
||||||
zoneNotReadyOrUnreachableTainer map[string]*RateLimitedTimedQueue
|
zoneNoExecuteTainer map[string]*RateLimitedTimedQueue
|
||||||
podEvictionTimeout time.Duration
|
podEvictionTimeout time.Duration
|
||||||
// The maximum duration before a pod evicted from a node can be forcefully terminated.
|
// The maximum duration before a pod evicted from a node can be forcefully terminated.
|
||||||
maximumGracePeriod time.Duration
|
maximumGracePeriod time.Duration
|
||||||
recorder record.EventRecorder
|
recorder record.EventRecorder
|
||||||
@ -241,33 +241,33 @@ func NewNodeController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
nc := &NodeController{
|
nc := &NodeController{
|
||||||
cloud: cloud,
|
cloud: cloud,
|
||||||
knownNodeSet: make(map[string]*v1.Node),
|
knownNodeSet: make(map[string]*v1.Node),
|
||||||
kubeClient: kubeClient,
|
kubeClient: kubeClient,
|
||||||
recorder: recorder,
|
recorder: recorder,
|
||||||
podEvictionTimeout: podEvictionTimeout,
|
podEvictionTimeout: podEvictionTimeout,
|
||||||
maximumGracePeriod: 5 * time.Minute,
|
maximumGracePeriod: 5 * time.Minute,
|
||||||
zonePodEvictor: make(map[string]*RateLimitedTimedQueue),
|
zonePodEvictor: make(map[string]*RateLimitedTimedQueue),
|
||||||
zoneNotReadyOrUnreachableTainer: make(map[string]*RateLimitedTimedQueue),
|
zoneNoExecuteTainer: make(map[string]*RateLimitedTimedQueue),
|
||||||
nodeStatusMap: make(map[string]nodeStatusData),
|
nodeStatusMap: make(map[string]nodeStatusData),
|
||||||
nodeMonitorGracePeriod: nodeMonitorGracePeriod,
|
nodeMonitorGracePeriod: nodeMonitorGracePeriod,
|
||||||
nodeMonitorPeriod: nodeMonitorPeriod,
|
nodeMonitorPeriod: nodeMonitorPeriod,
|
||||||
nodeStartupGracePeriod: nodeStartupGracePeriod,
|
nodeStartupGracePeriod: nodeStartupGracePeriod,
|
||||||
lookupIP: net.LookupIP,
|
lookupIP: net.LookupIP,
|
||||||
now: metav1.Now,
|
now: metav1.Now,
|
||||||
clusterCIDR: clusterCIDR,
|
clusterCIDR: clusterCIDR,
|
||||||
serviceCIDR: serviceCIDR,
|
serviceCIDR: serviceCIDR,
|
||||||
allocateNodeCIDRs: allocateNodeCIDRs,
|
allocateNodeCIDRs: allocateNodeCIDRs,
|
||||||
allocatorType: allocatorType,
|
allocatorType: allocatorType,
|
||||||
forcefullyDeletePod: func(p *v1.Pod) error { return forcefullyDeletePod(kubeClient, p) },
|
forcefullyDeletePod: func(p *v1.Pod) error { return forcefullyDeletePod(kubeClient, p) },
|
||||||
nodeExistsInCloudProvider: func(nodeName types.NodeName) (bool, error) { return nodeExistsInCloudProvider(cloud, nodeName) },
|
nodeExistsInCloudProvider: func(nodeName types.NodeName) (bool, error) { return nodeExistsInCloudProvider(cloud, nodeName) },
|
||||||
evictionLimiterQPS: evictionLimiterQPS,
|
evictionLimiterQPS: evictionLimiterQPS,
|
||||||
secondaryEvictionLimiterQPS: secondaryEvictionLimiterQPS,
|
secondaryEvictionLimiterQPS: secondaryEvictionLimiterQPS,
|
||||||
largeClusterThreshold: largeClusterThreshold,
|
largeClusterThreshold: largeClusterThreshold,
|
||||||
unhealthyZoneThreshold: unhealthyZoneThreshold,
|
unhealthyZoneThreshold: unhealthyZoneThreshold,
|
||||||
zoneStates: make(map[string]zoneState),
|
zoneStates: make(map[string]zoneState),
|
||||||
runTaintManager: runTaintManager,
|
runTaintManager: runTaintManager,
|
||||||
useTaintBasedEvictions: useTaintBasedEvictions && runTaintManager,
|
useTaintBasedEvictions: useTaintBasedEvictions && runTaintManager,
|
||||||
}
|
}
|
||||||
if useTaintBasedEvictions {
|
if useTaintBasedEvictions {
|
||||||
glog.Infof("NodeController is using taint based evictions.")
|
glog.Infof("NodeController is using taint based evictions.")
|
||||||
@ -434,12 +434,12 @@ func (nc *NodeController) doEvictionPass() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nc *NodeController) doTaintingPass() {
|
func (nc *NodeController) doNoExecuteTaintingPass() {
|
||||||
nc.evictorLock.Lock()
|
nc.evictorLock.Lock()
|
||||||
defer nc.evictorLock.Unlock()
|
defer nc.evictorLock.Unlock()
|
||||||
for k := range nc.zoneNotReadyOrUnreachableTainer {
|
for k := range nc.zoneNoExecuteTainer {
|
||||||
// Function should return 'false' and a time after which it should be retried, or 'true' if it shouldn't (it succeeded).
|
// Function should return 'false' and a time after which it should be retried, or 'true' if it shouldn't (it succeeded).
|
||||||
nc.zoneNotReadyOrUnreachableTainer[k].Try(func(value TimedValue) (bool, time.Duration) {
|
nc.zoneNoExecuteTainer[k].Try(func(value TimedValue) (bool, time.Duration) {
|
||||||
node, err := nc.nodeLister.Get(value.Value)
|
node, err := nc.nodeLister.Get(value.Value)
|
||||||
if apierrors.IsNotFound(err) {
|
if apierrors.IsNotFound(err) {
|
||||||
glog.Warningf("Node %v no longer present in nodeLister!", value.Value)
|
glog.Warningf("Node %v no longer present in nodeLister!", value.Value)
|
||||||
@ -498,7 +498,7 @@ func (nc *NodeController) Run(stopCh <-chan struct{}) {
|
|||||||
if nc.useTaintBasedEvictions {
|
if nc.useTaintBasedEvictions {
|
||||||
// Handling taint based evictions. Because we don't want a dedicated logic in TaintManager for NC-originated
|
// Handling taint based evictions. Because we don't want a dedicated logic in TaintManager for NC-originated
|
||||||
// taints and we normally don't rate limit evictions caused by taints, we need to rate limit adding taints.
|
// taints and we normally don't rate limit evictions caused by taints, we need to rate limit adding taints.
|
||||||
go wait.Until(nc.doTaintingPass, nodeEvictionPeriod, wait.NeverStop)
|
go wait.Until(nc.doNoExecuteTaintingPass, nodeEvictionPeriod, wait.NeverStop)
|
||||||
} else {
|
} else {
|
||||||
// Managing eviction of nodes:
|
// Managing eviction of nodes:
|
||||||
// When we delete pods off a node, if the node was not empty at the time we then
|
// When we delete pods off a node, if the node was not empty at the time we then
|
||||||
@ -519,7 +519,7 @@ func (nc *NodeController) addPodEvictorForNewZone(node *v1.Node) {
|
|||||||
NewRateLimitedTimedQueue(
|
NewRateLimitedTimedQueue(
|
||||||
flowcontrol.NewTokenBucketRateLimiter(nc.evictionLimiterQPS, evictionRateLimiterBurst))
|
flowcontrol.NewTokenBucketRateLimiter(nc.evictionLimiterQPS, evictionRateLimiterBurst))
|
||||||
} else {
|
} else {
|
||||||
nc.zoneNotReadyOrUnreachableTainer[zone] =
|
nc.zoneNoExecuteTainer[zone] =
|
||||||
NewRateLimitedTimedQueue(
|
NewRateLimitedTimedQueue(
|
||||||
flowcontrol.NewTokenBucketRateLimiter(nc.evictionLimiterQPS, evictionRateLimiterBurst))
|
flowcontrol.NewTokenBucketRateLimiter(nc.evictionLimiterQPS, evictionRateLimiterBurst))
|
||||||
}
|
}
|
||||||
@ -762,7 +762,7 @@ func (nc *NodeController) handleDisruption(zoneToNodeConditions map[string][]*v1
|
|||||||
// We stop all evictions.
|
// We stop all evictions.
|
||||||
for k := range nc.zoneStates {
|
for k := range nc.zoneStates {
|
||||||
if nc.useTaintBasedEvictions {
|
if nc.useTaintBasedEvictions {
|
||||||
nc.zoneNotReadyOrUnreachableTainer[k].SwapLimiter(0)
|
nc.zoneNoExecuteTainer[k].SwapLimiter(0)
|
||||||
} else {
|
} else {
|
||||||
nc.zonePodEvictor[k].SwapLimiter(0)
|
nc.zonePodEvictor[k].SwapLimiter(0)
|
||||||
}
|
}
|
||||||
@ -809,13 +809,13 @@ func (nc *NodeController) setLimiterInZone(zone string, zoneSize int, state zone
|
|||||||
switch state {
|
switch state {
|
||||||
case stateNormal:
|
case stateNormal:
|
||||||
if nc.useTaintBasedEvictions {
|
if nc.useTaintBasedEvictions {
|
||||||
nc.zoneNotReadyOrUnreachableTainer[zone].SwapLimiter(nc.evictionLimiterQPS)
|
nc.zoneNoExecuteTainer[zone].SwapLimiter(nc.evictionLimiterQPS)
|
||||||
} else {
|
} else {
|
||||||
nc.zonePodEvictor[zone].SwapLimiter(nc.evictionLimiterQPS)
|
nc.zonePodEvictor[zone].SwapLimiter(nc.evictionLimiterQPS)
|
||||||
}
|
}
|
||||||
case statePartialDisruption:
|
case statePartialDisruption:
|
||||||
if nc.useTaintBasedEvictions {
|
if nc.useTaintBasedEvictions {
|
||||||
nc.zoneNotReadyOrUnreachableTainer[zone].SwapLimiter(
|
nc.zoneNoExecuteTainer[zone].SwapLimiter(
|
||||||
nc.enterPartialDisruptionFunc(zoneSize))
|
nc.enterPartialDisruptionFunc(zoneSize))
|
||||||
} else {
|
} else {
|
||||||
nc.zonePodEvictor[zone].SwapLimiter(
|
nc.zonePodEvictor[zone].SwapLimiter(
|
||||||
@ -823,7 +823,7 @@ func (nc *NodeController) setLimiterInZone(zone string, zoneSize int, state zone
|
|||||||
}
|
}
|
||||||
case stateFullDisruption:
|
case stateFullDisruption:
|
||||||
if nc.useTaintBasedEvictions {
|
if nc.useTaintBasedEvictions {
|
||||||
nc.zoneNotReadyOrUnreachableTainer[zone].SwapLimiter(
|
nc.zoneNoExecuteTainer[zone].SwapLimiter(
|
||||||
nc.enterFullDisruptionFunc(zoneSize))
|
nc.enterFullDisruptionFunc(zoneSize))
|
||||||
} else {
|
} else {
|
||||||
nc.zonePodEvictor[zone].SwapLimiter(
|
nc.zonePodEvictor[zone].SwapLimiter(
|
||||||
@ -1066,7 +1066,7 @@ func (nc *NodeController) evictPods(node *v1.Node) bool {
|
|||||||
func (nc *NodeController) markNodeForTainting(node *v1.Node) bool {
|
func (nc *NodeController) markNodeForTainting(node *v1.Node) bool {
|
||||||
nc.evictorLock.Lock()
|
nc.evictorLock.Lock()
|
||||||
defer nc.evictorLock.Unlock()
|
defer nc.evictorLock.Unlock()
|
||||||
return nc.zoneNotReadyOrUnreachableTainer[utilnode.GetZoneKey(node)].Add(node.Name, string(node.UID))
|
return nc.zoneNoExecuteTainer[utilnode.GetZoneKey(node)].Add(node.Name, string(node.UID))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nc *NodeController) markNodeAsHealthy(node *v1.Node) (bool, error) {
|
func (nc *NodeController) markNodeAsHealthy(node *v1.Node) (bool, error) {
|
||||||
@ -1082,7 +1082,7 @@ func (nc *NodeController) markNodeAsHealthy(node *v1.Node) (bool, error) {
|
|||||||
glog.Errorf("Failed to remove taint from node %v: %v", node.Name, err)
|
glog.Errorf("Failed to remove taint from node %v: %v", node.Name, err)
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
return nc.zoneNotReadyOrUnreachableTainer[utilnode.GetZoneKey(node)].Remove(node.Name), nil
|
return nc.zoneNoExecuteTainer[utilnode.GetZoneKey(node)].Remove(node.Name), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default value for cluster eviction rate - we take nodeNum for consistency with ReducedQPSFunc.
|
// Default value for cluster eviction rate - we take nodeNum for consistency with ReducedQPSFunc.
|
||||||
|
@ -2005,7 +2005,7 @@ func TestSwapUnreachableNotReadyTaints(t *testing.T) {
|
|||||||
if err := nodeController.monitorNodeStatus(); err != nil {
|
if err := nodeController.monitorNodeStatus(); err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
nodeController.doTaintingPass()
|
nodeController.doNoExecuteTaintingPass()
|
||||||
|
|
||||||
node0, err := fakeNodeHandler.Get("node0", metav1.GetOptions{})
|
node0, err := fakeNodeHandler.Get("node0", metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -2043,7 +2043,7 @@ func TestSwapUnreachableNotReadyTaints(t *testing.T) {
|
|||||||
if err := nodeController.monitorNodeStatus(); err != nil {
|
if err := nodeController.monitorNodeStatus(); err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
nodeController.doTaintingPass()
|
nodeController.doNoExecuteTaintingPass()
|
||||||
|
|
||||||
node0, err = fakeNodeHandler.Get("node0", metav1.GetOptions{})
|
node0, err = fakeNodeHandler.Get("node0", metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user