mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Make taint behavior consistent, taint node with NotReady:NoSchedule
This commit is contained in:
parent
e72d54981a
commit
842ae0bc22
@ -80,15 +80,38 @@ var (
|
||||
Effect: v1.TaintEffectNoExecute,
|
||||
}
|
||||
|
||||
nodeConditionToTaintKeyMap = map[v1.NodeConditionType]string{
|
||||
v1.NodeMemoryPressure: algorithm.TaintNodeMemoryPressure,
|
||||
v1.NodeOutOfDisk: algorithm.TaintNodeOutOfDisk,
|
||||
v1.NodeDiskPressure: algorithm.TaintNodeDiskPressure,
|
||||
v1.NodeNetworkUnavailable: algorithm.TaintNodeNetworkUnavailable,
|
||||
v1.NodePIDPressure: algorithm.TaintNodePIDPressure,
|
||||
nodeConditionToTaintKeyStatusMap = map[v1.NodeConditionType]struct {
|
||||
TaintKey string
|
||||
Status v1.ConditionStatus
|
||||
}{
|
||||
v1.NodeReady: {
|
||||
TaintKey: algorithm.TaintNodeNotReady,
|
||||
Status: v1.ConditionFalse,
|
||||
},
|
||||
v1.NodeMemoryPressure: {
|
||||
TaintKey: algorithm.TaintNodeMemoryPressure,
|
||||
Status: v1.ConditionTrue,
|
||||
},
|
||||
v1.NodeOutOfDisk: {
|
||||
TaintKey: algorithm.TaintNodeOutOfDisk,
|
||||
Status: v1.ConditionTrue,
|
||||
},
|
||||
v1.NodeDiskPressure: {
|
||||
TaintKey: algorithm.TaintNodeDiskPressure,
|
||||
Status: v1.ConditionTrue,
|
||||
},
|
||||
v1.NodeNetworkUnavailable: {
|
||||
TaintKey: algorithm.TaintNodeNetworkUnavailable,
|
||||
Status: v1.ConditionTrue,
|
||||
},
|
||||
v1.NodePIDPressure: {
|
||||
TaintKey: algorithm.TaintNodePIDPressure,
|
||||
Status: v1.ConditionTrue,
|
||||
},
|
||||
}
|
||||
|
||||
taintKeyToNodeConditionMap = map[string]v1.NodeConditionType{
|
||||
algorithm.TaintNodeNotReady: v1.NodeReady,
|
||||
algorithm.TaintNodeNetworkUnavailable: v1.NodeNetworkUnavailable,
|
||||
algorithm.TaintNodeMemoryPressure: v1.NodeMemoryPressure,
|
||||
algorithm.TaintNodeOutOfDisk: v1.NodeOutOfDisk,
|
||||
@ -432,10 +455,10 @@ func (nc *Controller) doNoScheduleTaintingPass(node *v1.Node) error {
|
||||
// Map node's condition to Taints.
|
||||
taints := []v1.Taint{}
|
||||
for _, condition := range node.Status.Conditions {
|
||||
if _, found := nodeConditionToTaintKeyMap[condition.Type]; found {
|
||||
if condition.Status == v1.ConditionTrue {
|
||||
if taintKeyStatus, found := nodeConditionToTaintKeyStatusMap[condition.Type]; found {
|
||||
if condition.Status == taintKeyStatus.Status {
|
||||
taints = append(taints, v1.Taint{
|
||||
Key: nodeConditionToTaintKeyMap[condition.Type],
|
||||
Key: taintKeyStatus.TaintKey,
|
||||
Effect: v1.TaintEffectNoSchedule,
|
||||
})
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ func TestTaintNodeByCondition(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Case 4: Schedule Pod with NetworkUnavailable toleration.
|
||||
// Case 4: Schedule Pod with NetworkUnavailable and NotReady toleration.
|
||||
networkDaemonPod := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "network-daemon-pod",
|
||||
@ -248,6 +248,11 @@ func TestTaintNodeByCondition(t *testing.T) {
|
||||
Operator: v1.TolerationOpExists,
|
||||
Effect: v1.TaintEffectNoSchedule,
|
||||
},
|
||||
{
|
||||
Key: algorithm.TaintNodeNotReady,
|
||||
Operator: v1.TolerationOpExists,
|
||||
Effect: v1.TaintEffectNoSchedule,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user