Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29b09c7

Browse files
authored
Merge pull request kubernetes#87423 from soltysh/fix_tain_validation
Fix kubectl taint's Complete parsing
2 parents 703a719 + 6972d6f commit 29b09c7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

staging/src/k8s.io/kubectl/pkg/cmd/taint/taint.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (o *TaintOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
129129
taintArgs := []string{}
130130
metTaintArg := false
131131
for _, s := range args {
132-
isTaint := strings.Contains(s, "=") || strings.HasSuffix(s, "-")
132+
isTaint := strings.Contains(s, "=") || strings.Contains(s, ":") || strings.HasSuffix(s, "-")
133133
switch {
134134
case !metTaintArg && isTaint:
135135
metTaintArg = true

test/cmd/node-management.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,16 @@ __EOF__
7474
# taint/untaint
7575
# Pre-condition: node doesn't have dedicated=foo:PreferNoSchedule taint
7676
kube::test::get_object_assert "nodes 127.0.0.1" '{{range .spec.taints}}{{if eq .key \"dedicated\"}}{{.key}}={{.value}}:{{.effect}}{{end}}{{end}}' "" # expect no output
77-
# taint can add a taint
77+
# taint can add a taint (<key>=<value>:<effect>)
7878
kubectl taint node 127.0.0.1 dedicated=foo:PreferNoSchedule
7979
kube::test::get_object_assert "nodes 127.0.0.1" '{{range .spec.taints}}{{if eq .key \"dedicated\"}}{{.key}}={{.value}}:{{.effect}}{{end}}{{end}}' "dedicated=foo:PreferNoSchedule"
8080
# taint can remove a taint
8181
kubectl taint node 127.0.0.1 dedicated-
82+
# taint can add a taint (<key>:<effect>)
83+
kubectl taint node 127.0.0.1 dedicated:PreferNoSchedule
84+
kube::test::get_object_assert "nodes 127.0.0.1" '{{range .spec.taints}}{{if eq .key \"dedicated\"}}{{.key}}={{.value}}:{{.effect}}{{end}}{{end}}' "dedicated=<no value>:PreferNoSchedule"
85+
# taint can remove a taint
86+
kubectl taint node 127.0.0.1 dedicated-
8287
# Post-condition: node doesn't have dedicated=foo:PreferNoSchedule taint
8388
kube::test::get_object_assert "nodes 127.0.0.1" '{{range .spec.taints}}{{if eq .key \"dedicated\"}}{{.key}}={{.value}}:{{.effect}}{{end}}{{end}}' "" # expect no output
8489

0 commit comments

Comments
 (0)