Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix kubectl taint test flake #36820

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions test/e2e/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ func readTestFileOrDie(file string) []byte {
func runKubectlRetryOrDie(args ...string) string {
var err error
var output string
for i := 0; i < 3; i++ {
for i := 0; i < 5; i++ {
output, err = framework.RunKubectl(args...)
if err == nil || !strings.Contains(err.Error(), registry.OptimisticLockErrorMsg) {
if err == nil || (!strings.Contains(err.Error(), registry.OptimisticLockErrorMsg) && !strings.Contains(err.Error(), "Operation cannot be fulfilled")) {
break
}
time.Sleep(time.Second)
Expand Down Expand Up @@ -1355,18 +1355,17 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
framework.KubeDescribe("Kubectl taint", func() {
It("should update the taint on a node", func() {
testTaint := api.Taint{
Key: fmt.Sprintf("kubernetes.io/e2e-taint-key-%s", string(uuid.NewUUID())),
Key: fmt.Sprintf("kubernetes.io/e2e-taint-key-001-%s", string(uuid.NewUUID())),
Value: "testing-taint-value",
Effect: api.TaintEffectNoSchedule,
}

nodes, err := c.Core().Nodes().List(api.ListOptions{})
Expect(err).NotTo(HaveOccurred())
node := nodes.Items[0]
nodeName := node.Name
nodeName := getNodeThatCanRunPod(f)

By("adding the taint " + testTaint.ToString() + " to a node")
runKubectlRetryOrDie("taint", "nodes", nodeName, testTaint.ToString())
defer framework.RemoveTaintOffNode(f.ClientSet, nodeName, testTaint)

By("verifying the node has the taint " + testTaint.ToString())
output := runKubectlRetryOrDie("describe", "node", nodeName)
requiredStrings := [][]string{
Expand All @@ -1387,18 +1386,17 @@ var _ = framework.KubeDescribe("Kubectl client", func() {

It("should remove all the taints with the same key off a node", func() {
testTaint := api.Taint{
Key: fmt.Sprintf("kubernetes.io/e2e-taint-key-%s", string(uuid.NewUUID())),
Key: fmt.Sprintf("kubernetes.io/e2e-taint-key-002-%s", string(uuid.NewUUID())),
Value: "testing-taint-value",
Effect: api.TaintEffectNoSchedule,
}

nodes, err := c.Core().Nodes().List(api.ListOptions{})
Expect(err).NotTo(HaveOccurred())
node := nodes.Items[0]
nodeName := node.Name
nodeName := getNodeThatCanRunPod(f)

By("adding the taint " + testTaint.ToString() + " to a node")
runKubectlRetryOrDie("taint", "nodes", nodeName, testTaint.ToString())
defer framework.RemoveTaintOffNode(f.ClientSet, nodeName, testTaint)

By("verifying the node has the taint " + testTaint.ToString())
output := runKubectlRetryOrDie("describe", "node", nodeName)
requiredStrings := [][]string{
Expand All @@ -1415,6 +1413,8 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
}
By("adding another taint " + newTestTaint.ToString() + " to the node")
runKubectlRetryOrDie("taint", "nodes", nodeName, newTestTaint.ToString())
defer framework.RemoveTaintOffNode(f.ClientSet, nodeName, newTestTaint)

By("verifying the node has the taint " + newTestTaint.ToString())
output = runKubectlRetryOrDie("describe", "node", nodeName)
requiredStrings = [][]string{
Expand Down