mirror of https://github.com/k3s-io/k3s
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.pull/6/head
commit
922dff3e39
|
@ -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)
|
||||
|
@ -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{
|
||||
|
@ -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{
|
||||
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue