Merge pull request #28011 from mwielgus/node-pool-enable

Automatic merge from submit-queue

Use gcloud for default node pool and api for other in cluster autoscaler e2e test

cc: @piosz @jszczepkowski @fgrzadkowski 

Currently there is a problem with gcloud when non-default pool is used for cluster update. So we temporarily switch to the old ca-enable method for non-default pools until it is fixed.
This commit is contained in:
k8s-merge-robot 2016-06-24 03:56:37 -07:00 committed by GitHub
commit 35c9e9f74e

View File

@ -273,6 +273,10 @@ func isAutoscalerEnabled(expectedMinNodeCountInTargetPool int) (bool, error) {
} }
func enableAutoscaler(nodePool string, minCount, maxCount int) error { func enableAutoscaler(nodePool string, minCount, maxCount int) error {
if nodePool == "default-pool" {
glog.Infof("Using gcloud to enable autoscaling for pool %s", nodePool)
output, err := exec.Command("gcloud", "alpha", "container", "clusters", "update", framework.TestContext.CloudConfig.Cluster, output, err := exec.Command("gcloud", "alpha", "container", "clusters", "update", framework.TestContext.CloudConfig.Cluster,
"--enable-autoscaling", "--enable-autoscaling",
"--min-nodes="+strconv.Itoa(minCount), "--min-nodes="+strconv.Itoa(minCount),
@ -286,6 +290,28 @@ func enableAutoscaler(nodePool string, minCount, maxCount int) error {
} }
glog.Infof("Config update result: %s", output) glog.Infof("Config update result: %s", output)
} else {
glog.Infof("Using direct api access to enable autoscaling for pool %s", nodePool)
updateRequest := "{" +
" \"update\": {" +
" \"desiredNodePoolId\": \"" + nodePool + "\"," +
" \"desiredNodePoolAutoscaling\": {" +
" \"enabled\": \"true\"," +
" \"minNodeCount\": \"" + strconv.Itoa(minCount) + "\"," +
" \"maxNodeCount\": \"" + strconv.Itoa(maxCount) + "\"" +
" }" +
" }" +
"}"
url := getGKEClusterUrl()
glog.Infof("Using gke api url %s", url)
putResult, err := doPut(url, updateRequest)
if err != nil {
return fmt.Errorf("Failed to put %s: %v", url, err)
}
glog.Infof("Config update result: %s", putResult)
}
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 { if val, err := isAutoscalerEnabled(minCount); err == nil && val {
return nil return nil