Merge pull request #53057 from aleksandra-malinowska/autoscaling-test-fix-8

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

In autoscaling tests, add waiting for new pool to become ready

This adds missing timeout when adding a node pool in GKE scale to 0 test and improves logging error when enabling autoscaling.
This commit is contained in:
Kubernetes Submit Queue 2017-09-26 15:41:47 -07:00 committed by GitHub
commit 0ebe86019c

View File

@ -623,11 +623,12 @@ var _ = SIGDescribe("Cluster size autoscaling [Slow]", func() {
// Determine whether we want to run & adjust the setup if necessary // Determine whether we want to run & adjust the setup if necessary
if len(originalSizes) < 2 { if len(originalSizes) < 2 {
if framework.ProviderIs("gke") { if framework.ProviderIs("gke") {
By("Adding a new node pool")
const extraPoolName = "extra-pool" const extraPoolName = "extra-pool"
addNodePool(extraPoolName, "n1-standard-4", 1) addNodePool(extraPoolName, "n1-standard-4", 1)
defer deleteNodePool(extraPoolName) defer deleteNodePool(extraPoolName)
err := enableAutoscaler(extraPoolName, 0, 1) framework.ExpectNoError(framework.WaitForReadyNodes(c, nodeCount+1, resizeTimeout))
framework.ExpectNoError(err) framework.ExpectNoError(enableAutoscaler(extraPoolName, 0, 1))
} else { } else {
framework.Skipf("At least 2 node groups are needed for scale-to-0 tests") framework.Skipf("At least 2 node groups are needed for scale-to-0 tests")
} }
@ -831,12 +832,15 @@ func enableAutoscaler(nodePool string, minCount, maxCount int) error {
glog.Infof("Config update result: %s", putResult) glog.Infof("Config update result: %s", putResult)
} }
var finalErr error
for startTime := time.Now(); startTime.Add(gkeUpdateTimeout).After(time.Now()); time.Sleep(30 * time.Second) { for startTime := time.Now(); startTime.Add(gkeUpdateTimeout).After(time.Now()); time.Sleep(30 * time.Second) {
if val, err := isAutoscalerEnabled(minCount); err == nil && val { val, err := isAutoscalerEnabled(minCount)
if err == nil && val {
return nil return nil
} }
finalErr = err
} }
return fmt.Errorf("autoscaler not enabled") return fmt.Errorf("autoscaler not enabled, last error: %v", finalErr)
} }
func disableAutoscaler(nodePool string, minCount, maxCount int) error { func disableAutoscaler(nodePool string, minCount, maxCount int) error {