Merge pull request #11692 from wojtek-t/new_api_instance_groups

Auto commit by PR queue bot
This commit is contained in:
Brendan Burns
2015-08-03 11:07:36 -07:00
5 changed files with 29 additions and 60 deletions

View File

@@ -526,13 +526,12 @@ func migTemplate() (string, error) {
if wait.Poll(poll, singleCallTimeout, func() (bool, error) {
// TODO(mbforbes): make this hit the compute API directly instead of
// shelling out to gcloud.
o, err := exec.Command("gcloud", "preview", "managed-instance-groups",
o, err := exec.Command("gcloud", "compute", "instance-groups", "managed",
"describe", testContext.CloudConfig.NodeInstanceGroup,
fmt.Sprintf("--project=%s", testContext.CloudConfig.ProjectID),
fmt.Sprintf("--zone=%s", testContext.CloudConfig.Zone),
"describe",
testContext.CloudConfig.NodeInstanceGroup).CombinedOutput()
fmt.Sprintf("--zone=%s", testContext.CloudConfig.Zone)).CombinedOutput()
if err != nil {
errLast = fmt.Errorf("gcloud preview managed-instance-groups describe call failed with err: %v", err)
errLast = fmt.Errorf("gcloud compute instance-groups managed describe call failed with err: %v", err)
return false, nil
}
output := string(o)

View File

@@ -19,8 +19,7 @@ package e2e
import (
"fmt"
"os/exec"
"strconv"
"strings"
"regexp"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
@@ -45,8 +44,9 @@ func resizeGroup(size int) error {
if testContext.Provider == "gce" || testContext.Provider == "gke" {
// TODO: make this hit the compute API directly instead of shelling out to gcloud.
// TODO: make gce/gke implement InstanceGroups, so we can eliminate the per-provider logic
output, err := exec.Command("gcloud", "preview", "managed-instance-groups", "--project="+testContext.CloudConfig.ProjectID, "--zone="+testContext.CloudConfig.Zone,
"resize", testContext.CloudConfig.NodeInstanceGroup, fmt.Sprintf("--new-size=%v", size)).CombinedOutput()
output, err := exec.Command("gcloud", "compute", "instance-groups", "managed", "resize",
testContext.CloudConfig.NodeInstanceGroup, fmt.Sprintf("--size=%v", size),
"--project="+testContext.CloudConfig.ProjectID, "--zone="+testContext.CloudConfig.Zone).CombinedOutput()
if err != nil {
Logf("Failed to resize node instance group: %v", string(output))
}
@@ -65,27 +65,14 @@ func groupSize() (int, error) {
if testContext.Provider == "gce" || testContext.Provider == "gke" {
// TODO: make this hit the compute API directly instead of shelling out to gcloud.
// TODO: make gce/gke implement InstanceGroups, so we can eliminate the per-provider logic
output, err := exec.Command("gcloud", "preview", "managed-instance-groups", "--project="+testContext.CloudConfig.ProjectID,
"--zone="+testContext.CloudConfig.Zone, "describe", testContext.CloudConfig.NodeInstanceGroup).CombinedOutput()
output, err := exec.Command("gcloud", "compute", "instance-groups", "managed",
"list-instances", testContext.CloudConfig.NodeInstanceGroup, "--project="+testContext.CloudConfig.ProjectID,
"--zone="+testContext.CloudConfig.Zone).CombinedOutput()
if err != nil {
return -1, err
}
pattern := "currentSize: "
i := strings.Index(string(output), pattern)
if i == -1 {
return -1, fmt.Errorf("could not find '%s' in the output '%s'", pattern, output)
}
truncated := output[i+len(pattern):]
j := strings.Index(string(truncated), "\n")
if j == -1 {
return -1, fmt.Errorf("could not find new line in the truncated output '%s'", truncated)
}
currentSize, err := strconv.Atoi(string(truncated[:j]))
if err != nil {
return -1, err
}
return currentSize, nil
re := regexp.MustCompile("RUNNING")
return len(re.FindAllString(string(output), -1)), nil
} else {
// Supported by aws
instanceGroups, ok := testContext.CloudConfig.Provider.(aws_cloud.InstanceGroups)

View File

@@ -232,13 +232,13 @@ func restartNodes(provider string, nt time.Duration) error {
// done
//
// # Step 2: Start the recreate.
// output=$(gcloud preview managed-instance-groups --project=${PROJECT} --zone=${ZONE} recreate-instances ${GROUP} --instance="${i}")
// output=$(gcloud compute instance-groups managed --project=${PROJECT} --zone=${ZONE} recreate-instances ${GROUP} --instance="${i}")
// op=${output##*:}
//
// # Step 3: Wait until it's complete.
// status=""
// while [[ "${status}" != "DONE" ]]; do
// output=$(gcloud preview managed-instance-groups --zone="${ZONE}" get-operation ${op} | grep status)
// output=$(gcloud compute instance-groups managed --zone="${ZONE}" get-operation ${op} | grep status)
// status=${output##*:}
// done
func migRollingUpdateSelf(nt time.Duration) error {