Skip to content

Commit

Permalink
Adds retry for adding/removing annotations during IT (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mkmittal authored Jun 15, 2022
1 parent 9ef09a6 commit 1badf42
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cluster-autoscaler/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io/ioutil"
"k8s.io/client-go/util/retry"
"os"
"regexp"
"time"
Expand Down Expand Up @@ -145,10 +146,13 @@ func (driver *Driver) controllerTests() {
pollingTimeout,
pollingInterval).
Should(BeNumerically("==", initialNumberOfNodes+1))
By("getting the latest added node and adding annotation to it.")
_, latestNode, err := driver.getOldestAndLatestNode()
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
By("getting the latest added node and adding annotation to it.")
_, latestNode, err := driver.getOldestAndLatestNode()
Expect(err).To(BeNil())
return driver.addAnnotationToNode(latestNode)
})
Expect(err).To(BeNil())
Expect(driver.addAnnotationToNode(latestNode)).To(BeNil())
By("Scaling down workload to zero...")
Expect(driver.scaleWorkload(scaleUpWorkload, 0)).To(BeNil())
skippedRegexp, _ := regexp.Compile(` the node is marked as no scale down`)
Expand All @@ -160,9 +164,13 @@ func (driver *Driver) controllerTests() {

It("Should remove the unwanted node once scale down disable annotation is removed", func() {
Expect(driver.targetCluster.getNumberOfReadyNodes()).Should(BeNumerically("==", initialNumberOfNodes+1))
_, latestNode, err := driver.getOldestAndLatestNode()
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
By("getting the latest added node and removing annotation from it.")
_, latestNode, err := driver.getOldestAndLatestNode()
Expect(err).To(BeNil())
return driver.removeAnnotationFromNode(latestNode)
})
Expect(err).To(BeNil())
Expect(driver.removeAnnotationFromNode(latestNode)).To(BeNil())
By("Validating Scale down")
Eventually(
driver.targetCluster.getNumberOfReadyNodes,
Expand Down

0 comments on commit 1badf42

Please sign in to comment.