Commit 922dff3e authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #36820 from kevin-wangzefeng/fix-kubectl-taint-flake

Automatic merge from submit-queue fix kubectl taint test flake <!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, read our contributor guidelines https://github.com/kubernetes/kubernetes/blob/master/CONTRIBUTING.md and developer guide https://github.com/kubernetes/kubernetes/blob/master/docs/devel/development.md 2. If you want *faster* PR reviews, read how: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/faster_reviews.md 3. Follow the instructions for writing a release note: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/pull-requests.md#release-notes --> **What this PR does / why we need it**: Kubectl taint tests fail often recently, this PR is trying to fix it. **Which issue this PR fixes**: ref #29503, #32535 **Special notes for your reviewer**: This PR cannot 100% fix the flake, but just reduce the failing rate, if the two "kubectl taint" tests are running at the same time, it still has chance to fail. Maybe should mark the tests "Serial" (see also #31906, #36781), but then they won't run for each PR.
parents 0f95b262 6211669a
...@@ -156,9 +156,9 @@ func readTestFileOrDie(file string) []byte { ...@@ -156,9 +156,9 @@ func readTestFileOrDie(file string) []byte {
func runKubectlRetryOrDie(args ...string) string { func runKubectlRetryOrDie(args ...string) string {
var err error var err error
var output string var output string
for i := 0; i < 3; i++ { for i := 0; i < 5; i++ {
output, err = framework.RunKubectl(args...) 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 break
} }
time.Sleep(time.Second) time.Sleep(time.Second)
...@@ -1355,18 +1355,17 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -1355,18 +1355,17 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
framework.KubeDescribe("Kubectl taint", func() { framework.KubeDescribe("Kubectl taint", func() {
It("should update the taint on a node", func() { It("should update the taint on a node", func() {
testTaint := api.Taint{ 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", Value: "testing-taint-value",
Effect: api.TaintEffectNoSchedule, Effect: api.TaintEffectNoSchedule,
} }
nodes, err := c.Core().Nodes().List(api.ListOptions{}) nodeName := getNodeThatCanRunPod(f)
Expect(err).NotTo(HaveOccurred())
node := nodes.Items[0]
nodeName := node.Name
By("adding the taint " + testTaint.ToString() + " to a node") By("adding the taint " + testTaint.ToString() + " to a node")
runKubectlRetryOrDie("taint", "nodes", nodeName, testTaint.ToString()) runKubectlRetryOrDie("taint", "nodes", nodeName, testTaint.ToString())
defer framework.RemoveTaintOffNode(f.ClientSet, nodeName, testTaint)
By("verifying the node has the taint " + testTaint.ToString()) By("verifying the node has the taint " + testTaint.ToString())
output := runKubectlRetryOrDie("describe", "node", nodeName) output := runKubectlRetryOrDie("describe", "node", nodeName)
requiredStrings := [][]string{ requiredStrings := [][]string{
...@@ -1387,18 +1386,17 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -1387,18 +1386,17 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
It("should remove all the taints with the same key off a node", func() { It("should remove all the taints with the same key off a node", func() {
testTaint := api.Taint{ 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", Value: "testing-taint-value",
Effect: api.TaintEffectNoSchedule, Effect: api.TaintEffectNoSchedule,
} }
nodes, err := c.Core().Nodes().List(api.ListOptions{}) nodeName := getNodeThatCanRunPod(f)
Expect(err).NotTo(HaveOccurred())
node := nodes.Items[0]
nodeName := node.Name
By("adding the taint " + testTaint.ToString() + " to a node") By("adding the taint " + testTaint.ToString() + " to a node")
runKubectlRetryOrDie("taint", "nodes", nodeName, testTaint.ToString()) runKubectlRetryOrDie("taint", "nodes", nodeName, testTaint.ToString())
defer framework.RemoveTaintOffNode(f.ClientSet, nodeName, testTaint)
By("verifying the node has the taint " + testTaint.ToString()) By("verifying the node has the taint " + testTaint.ToString())
output := runKubectlRetryOrDie("describe", "node", nodeName) output := runKubectlRetryOrDie("describe", "node", nodeName)
requiredStrings := [][]string{ requiredStrings := [][]string{
...@@ -1415,6 +1413,8 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -1415,6 +1413,8 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
} }
By("adding another taint " + newTestTaint.ToString() + " to the node") By("adding another taint " + newTestTaint.ToString() + " to the node")
runKubectlRetryOrDie("taint", "nodes", nodeName, newTestTaint.ToString()) runKubectlRetryOrDie("taint", "nodes", nodeName, newTestTaint.ToString())
defer framework.RemoveTaintOffNode(f.ClientSet, nodeName, newTestTaint)
By("verifying the node has the taint " + newTestTaint.ToString()) By("verifying the node has the taint " + newTestTaint.ToString())
output = runKubectlRetryOrDie("describe", "node", nodeName) output = runKubectlRetryOrDie("describe", "node", nodeName)
requiredStrings = [][]string{ requiredStrings = [][]string{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment