mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #91024 from ingvagabund/display-tolerations-just-with-exists-operator
kubectl describe: print toleration tolerating everything
This commit is contained in:
commit
5b0d8d2ce1
@ -4606,6 +4606,17 @@ func printTolerationsMultilineWithIndent(w PrefixWriter, initialIndent, title, i
|
||||
if len(toleration.Effect) != 0 {
|
||||
w.Write(LEVEL_0, ":%s", toleration.Effect)
|
||||
}
|
||||
// tolerations:
|
||||
// - operator: "Exists"
|
||||
// is a special case which tolerates everything
|
||||
if toleration.Operator == corev1.TolerationOpExists && len(toleration.Value) == 0 {
|
||||
if len(toleration.Key) != 0 {
|
||||
w.Write(LEVEL_0, " op=Exists")
|
||||
} else {
|
||||
w.Write(LEVEL_0, "op=Exists")
|
||||
}
|
||||
}
|
||||
|
||||
if toleration.TolerationSeconds != nil {
|
||||
w.Write(LEVEL_0, " for %ds", *toleration.TolerationSeconds)
|
||||
}
|
||||
|
@ -179,6 +179,7 @@ func TestDescribePodTolerations(t *testing.T) {
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
Tolerations: []corev1.Toleration{
|
||||
{Operator: corev1.TolerationOpExists},
|
||||
{Key: "key0", Operator: corev1.TolerationOpExists},
|
||||
{Key: "key1", Value: "value1"},
|
||||
{Key: "key2", Operator: corev1.TolerationOpEqual, Value: "value2", Effect: corev1.TaintEffectNoSchedule},
|
||||
@ -193,7 +194,8 @@ func TestDescribePodTolerations(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if !strings.Contains(out, "key0\n") ||
|
||||
if !strings.Contains(out, " op=Exists\n") ||
|
||||
!strings.Contains(out, "key0 op=Exists\n") ||
|
||||
!strings.Contains(out, "key1=value1\n") ||
|
||||
!strings.Contains(out, "key2=value2:NoSchedule\n") ||
|
||||
!strings.Contains(out, "key3=value3:NoExecute for 300s\n") ||
|
||||
|
Loading…
Reference in New Issue
Block a user