Merge pull request #91024 from ingvagabund/display-tolerations-just-with-exists-operator

kubectl describe: print toleration tolerating everything
This commit is contained in:
Kubernetes Prow Robot 2020-05-15 02:48:21 -07:00 committed by GitHub
commit 5b0d8d2ce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -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)
}

View File

@ -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") ||