mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Support gcloud rolling-update command in 'preview' and 'alpha compute'
This commit is contained in:
parent
b9e974b2cf
commit
5ff1566aac
@ -212,8 +212,15 @@ function do-node-upgrade() {
|
|||||||
echo "== Upgrading nodes to ${KUBE_VERSION}. ==" >&2
|
echo "== Upgrading nodes to ${KUBE_VERSION}. ==" >&2
|
||||||
# Do the actual upgrade.
|
# Do the actual upgrade.
|
||||||
# NOTE(mbforbes): If you are changing this gcloud command, update
|
# NOTE(mbforbes): If you are changing this gcloud command, update
|
||||||
# test/e2e/restart.go to match this EXACTLY.
|
# test/e2e/cluster_upgrade.go to match this EXACTLY.
|
||||||
gcloud preview rolling-updates \
|
# TODO(mbforbes): Remove this hack on July 29, 2015, when the migration to
|
||||||
|
# `gcloud alpha compute rolling-updates` is complete.
|
||||||
|
local subgroup="preview"
|
||||||
|
local exists=$(gcloud ${subgroup} rolling-updates -h &>/dev/null; echo $?) || true
|
||||||
|
if [[ "${exists}" != "0" ]]; then
|
||||||
|
subgroup="alpha compute"
|
||||||
|
fi
|
||||||
|
gcloud ${subgroup} rolling-updates \
|
||||||
--project="${PROJECT}" \
|
--project="${PROJECT}" \
|
||||||
--zone="${ZONE}" \
|
--zone="${ZONE}" \
|
||||||
start \
|
start \
|
||||||
|
@ -567,7 +567,8 @@ func migRollingUpdateStart(templ string, nt time.Duration) (string, error) {
|
|||||||
// shelling out to gcloud.
|
// shelling out to gcloud.
|
||||||
// NOTE(mbforbes): If you are changing this gcloud command, update
|
// NOTE(mbforbes): If you are changing this gcloud command, update
|
||||||
// cluster/gce/upgrade.sh to match this EXACTLY.
|
// cluster/gce/upgrade.sh to match this EXACTLY.
|
||||||
o, err := exec.Command("gcloud", "preview", "rolling-updates",
|
o, err := exec.Command("gcloud", append(migUdpateCmdBase(),
|
||||||
|
"rolling-updates",
|
||||||
fmt.Sprintf("--project=%s", testContext.CloudConfig.ProjectID),
|
fmt.Sprintf("--project=%s", testContext.CloudConfig.ProjectID),
|
||||||
fmt.Sprintf("--zone=%s", testContext.CloudConfig.Zone),
|
fmt.Sprintf("--zone=%s", testContext.CloudConfig.Zone),
|
||||||
"start",
|
"start",
|
||||||
@ -580,9 +581,9 @@ func migRollingUpdateStart(templ string, nt time.Duration) (string, error) {
|
|||||||
// --max-num-concurrent-instances.
|
// --max-num-concurrent-instances.
|
||||||
fmt.Sprintf("--max-num-concurrent-instances=%d", 1),
|
fmt.Sprintf("--max-num-concurrent-instances=%d", 1),
|
||||||
fmt.Sprintf("--max-num-failed-instances=%d", 0),
|
fmt.Sprintf("--max-num-failed-instances=%d", 0),
|
||||||
fmt.Sprintf("--min-instance-update-time=%ds", 0)).CombinedOutput()
|
fmt.Sprintf("--min-instance-update-time=%ds", 0))...).CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errLast = fmt.Errorf("gcloud preview rolling-updates call failed with err: %v", err)
|
errLast = fmt.Errorf("rolling-updates call failed with err: %v", err)
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
output := string(o)
|
output := string(o)
|
||||||
@ -609,6 +610,25 @@ func migRollingUpdateStart(templ string, nt time.Duration) (string, error) {
|
|||||||
return id, nil
|
return id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// migUpdateCmdBase gets the base of the MIG rolling update command--i.e., all
|
||||||
|
// pieces of the gcloud command that come after "gcloud" but before
|
||||||
|
// "rolling-updates". Examples of returned values are:
|
||||||
|
//
|
||||||
|
// {preview"}
|
||||||
|
//
|
||||||
|
// {"alpha", "compute"}
|
||||||
|
//
|
||||||
|
// TODO(mbforbes): Remove this hack on July 29, 2015 when the migration to
|
||||||
|
// `gcloud alpha compute rolling-updates` is complete.
|
||||||
|
func migUdpateCmdBase() []string {
|
||||||
|
b := []string{"preview"}
|
||||||
|
a := []string{"rolling-updates", "-h"}
|
||||||
|
if err := exec.Command("gcloud", append(b, a...)...).Run(); err != nil {
|
||||||
|
b = []string{"alpha", "compute"}
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
// migRollingUpdatePoll (CKE/GKE-only) polls the progress of the MIG rolling
|
// migRollingUpdatePoll (CKE/GKE-only) polls the progress of the MIG rolling
|
||||||
// update with ID id until it is complete. It returns an error if this takes
|
// update with ID id until it is complete. It returns an error if this takes
|
||||||
// longer than nt times the number of nodes.
|
// longer than nt times the number of nodes.
|
||||||
@ -620,11 +640,12 @@ func migRollingUpdatePoll(id string, nt time.Duration) error {
|
|||||||
Logf("Waiting up to %v for MIG rolling update to complete.", timeout)
|
Logf("Waiting up to %v for MIG rolling update to complete.", timeout)
|
||||||
// TODO(mbforbes): Refactor this to use cluster_upgrade.go:retryCmd(...)
|
// TODO(mbforbes): Refactor this to use cluster_upgrade.go:retryCmd(...)
|
||||||
if wait.Poll(restartPoll, timeout, func() (bool, error) {
|
if wait.Poll(restartPoll, timeout, func() (bool, error) {
|
||||||
o, err := exec.Command("gcloud", "preview", "rolling-updates",
|
o, err := exec.Command("gcloud", append(migUdpateCmdBase(),
|
||||||
|
"rolling-updates",
|
||||||
fmt.Sprintf("--project=%s", testContext.CloudConfig.ProjectID),
|
fmt.Sprintf("--project=%s", testContext.CloudConfig.ProjectID),
|
||||||
fmt.Sprintf("--zone=%s", testContext.CloudConfig.Zone),
|
fmt.Sprintf("--zone=%s", testContext.CloudConfig.Zone),
|
||||||
"describe",
|
"describe",
|
||||||
id).CombinedOutput()
|
id)...).CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errLast = fmt.Errorf("Error calling rolling-updates describe %s: %v", id, err)
|
errLast = fmt.Errorf("Error calling rolling-updates describe %s: %v", id, err)
|
||||||
Logf("%v", errLast)
|
Logf("%v", errLast)
|
||||||
|
Loading…
Reference in New Issue
Block a user