Upgrades and upgrade tests take versions of the form release/stable instead of stable_release:

- Refactor common and gce/upgrade.sh to use arbitrary published releases
- Update hack/get-build to use cluster/common code
- Use hack/get-build.sh in cluster upgrade test logic
pull/6/head
Isaac Hollander McCreery 2015-10-12 16:11:12 -07:00
parent e929977ff3
commit 60c316b54a
8 changed files with 120 additions and 141 deletions

View File

@ -24,6 +24,13 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
DEFAULT_KUBECONFIG="${HOME}/.kube/config"
# KUBE_VERSION_REGEX matches things like "v1.2.3"
KUBE_VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
# KUBE_CI_VERSION_REGEX matches things like "v1.2.3-alpha.4.56+abcdefg"
KUBE_CI_VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-(.*)$"
# Generate kubeconfig data for the created cluster.
# Assumed vars:
# KUBE_USER
@ -224,23 +231,20 @@ function detect-master-from-kubeconfig() {
fi
}
# Sets KUBE_VERSION variable to the version passed in as an argument, or if argument is
# latest_stable, latest_release, or latest_ci fetches and sets the corresponding version number
# Sets KUBE_VERSION variable to the proper version number (e.g. "v1.0.6",
# "v1.2.0-alpha.1.881+376438b69c7612") or a version' publication of the form
# <bucket>/<version> (e.g. "release/stable",' "ci/latest-1").
#
# See the docs on getting builds for more information about version
# publication.
#
# Args:
# $1 version string from command line
# Vars set:
# KUBE_VERSION
function set_binary_version() {
if [[ "${1}" == "latest_stable" ]]; then
KUBE_VERSION=$(gsutil cat gs://kubernetes-release/release/stable.txt)
echo "Using latest stable version: ${KUBE_VERSION}" >&2
elif [[ "${1}" == "latest_release" ]]; then
KUBE_VERSION=$(gsutil cat gs://kubernetes-release/release/latest.txt)
echo "Using latest release version: ${KUBE_VERSION}" >&2
elif [[ "${1}" == "latest_ci" ]]; then
KUBE_VERSION=$(gsutil cat gs://kubernetes-release/ci/latest.txt)
echo "Using latest ci version: ${KUBE_VERSION}" >&2
if [[ "${1}" =~ "/" ]]; then
KUBE_VERSION=$(gsutil cat gs://kubernetes-release/${1}.txt)
else
KUBE_VERSION=${1}
fi
@ -251,8 +255,11 @@ function set_binary_version() {
# use local dev binaries.
#
# Assumed vars:
# PROJECT
# KUBE_VERSION_REGEX
# KUBE_CI_VERSION_REGEX
# Vars set:
# KUBE_TAR_URL
# KUBE_TAR_HASH
# SERVER_BINARY_TAR_URL
# SERVER_BINARY_TAR_HASH
# SALT_TAR_URL
@ -262,15 +269,20 @@ function tars_from_version() {
find-release-tars
upload-server-tars
elif [[ ${KUBE_VERSION} =~ ${KUBE_VERSION_REGEX} ]]; then
KUBE_TAR_URL="https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/kubernetes.tar.gz"
SERVER_BINARY_TAR_URL="https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/kubernetes-server-linux-amd64.tar.gz"
SALT_TAR_URL="https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/kubernetes-salt.tar.gz"
elif [[ ${KUBE_VERSION} =~ ${KUBE_CI_VERSION_REGEX} ]]; then
KUBE_TAR_URL="https://storage.googleapis.com/kubernetes-release/ci/${KUBE_VERSION}/kubernetes.tar.gz"
SERVER_BINARY_TAR_URL="https://storage.googleapis.com/kubernetes-release/ci/${KUBE_VERSION}/kubernetes-server-linux-amd64.tar.gz"
SALT_TAR_URL="https://storage.googleapis.com/kubernetes-release/ci/${KUBE_VERSION}/kubernetes-salt.tar.gz"
else
echo "Version doesn't match regexp" >&2
exit 1
fi
until KUBE_TAR_HASH=$(curl --fail --silent "${KUBE_TAR_URL}.sha1"); do
echo "Failure trying to curl release .sha1"
done
until SERVER_BINARY_TAR_HASH=$(curl --fail --silent "${SERVER_BINARY_TAR_URL}.sha1"); do
echo "Failure trying to curl release .sha1"
done
@ -278,6 +290,10 @@ function tars_from_version() {
echo "Failure trying to curl Salt tar .sha1"
done
if ! curl -Ss --range 0-1 "${KUBE_TAR_URL}" >&/dev/null; then
echo "Can't find release at ${KUBE_TAR_URL}" >&2
exit 1
fi
if ! curl -Ss --range 0-1 "${SERVER_BINARY_TAR_URL}" >&/dev/null; then
echo "Can't find release at ${SERVER_BINARY_TAR_URL}" >&2
exit 1

View File

@ -34,29 +34,38 @@ source "${KUBE_ROOT}/cluster/kube-util.sh"
function usage() {
echo "!!! EXPERIMENTAL !!!"
echo ""
echo "${0} [-M|-N|-P] -l | <release or continuous integration version> | [latest_stable|latest_release|latest_ci]"
echo "${0} [-M|-N|-P] -l | <version number or publication>"
echo " Upgrades master and nodes by default"
echo " -M: Upgrade master only"
echo " -N: Upgrade nodes only"
echo " -P: Node upgrade prerequisites only (create a new instance template)"
echo " -l: Use local(dev) binaries"
echo ""
echo ' Version number or publication is either a proper version number'
echo ' (e.g. "v1.0.6", "v1.2.0-alpha.1.881+376438b69c7612") or a version'
echo ' publication of the form <bucket>/<version> (e.g. "release/stable",'
echo ' "ci/latest-1"). Some common ones are:'
echo ' - "release/stable"'
echo ' - "release/latest"'
echo ' - "ci/latest"'
echo ' See the docs on getting builds for more information about version publication.'
echo ""
echo "(... Fetching current release versions ...)"
echo ""
# NOTE: IF YOU CHANGE THE FOLLOWING LIST, ALSO UPDATE test/e2e/cluster_upgrade.go
local latest_release
local latest_stable
local latest_ci
local release_stable
local release_latest
local ci_latest
latest_stable=$(gsutil cat gs://kubernetes-release/release/stable.txt)
latest_release=$(gsutil cat gs://kubernetes-release/release/latest.txt)
latest_ci=$(gsutil cat gs://kubernetes-release/ci/latest.txt)
release_stable=$(gsutil cat gs://kubernetes-release/release/stable.txt)
release_latest=$(gsutil cat gs://kubernetes-release/release/latest.txt)
ci_latest=$(gsutil cat gs://kubernetes-release/ci/latest.txt)
echo "To upgrade to:"
echo " latest stable: ${0} ${latest_stable}"
echo " latest release: ${0} ${latest_release}"
echo " latest ci: ${0} ${latest_ci}"
echo "Right now, versions are as follows:"
echo " release/stable: ${0} ${release_stable}"
echo " release/latest: ${0} ${release_latest}"
echo " ci/latest: ${0} ${ci_latest}"
}
function upgrade-master() {

View File

@ -42,13 +42,6 @@ KUBE_GCS_STAGING_PATH_SUFFIX=${KUBE_GCS_STAGING_PATH_SUFFIX-""}
# How long (in seconds) to wait for cluster initialization.
KUBE_CLUSTER_INITIALIZATION_TIMEOUT=${KUBE_CLUSTER_INITIALIZATION_TIMEOUT:-300}
# VERSION_REGEX matches things like "v0.13.1"
readonly KUBE_VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
# CI_VERSION_REGEX matches things like "v0.14.1-341-ge0c9d9e"
readonly KUBE_CI_VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-(.*)$"
function join_csv {
local IFS=','; echo "$*";
}

View File

@ -74,16 +74,7 @@ The node upgrade process is user-initiated and is described in the [GKE document
Upgrades on open source Google Compute Engine (GCE) clusters are controlled by the `cluster/gce/upgrade.sh` script.
Its usage is as follows:
```console
cluster/gce/upgrade.sh [-M|-N|-P] -l | <release or continuous integration version> | [latest_stable|latest_release|latest_ci]
Upgrades master and nodes by default
-M: Upgrade master only
-N: Upgrade nodes only
-P: Node upgrade prerequisites only (create a new instance template)
-l: Use local(dev) binaries
```
Get its usage by running `cluster/gce/upgrade.sh -h`.
For example, to upgrade just your master to a specific version (v1.0.2):
@ -94,7 +85,7 @@ cluster/gce/upgrade.sh -M v1.0.2
Alternatively, to upgrade your entire cluster to the latest stable release:
```console
cluster/gce/upgrade.sh latest_stable
cluster/gce/upgrade.sh release/stable
```
### Other platforms

View File

@ -35,17 +35,27 @@ Documentation for other releases can be found at
You can use [hack/get-build.sh](http://releases.k8s.io/HEAD/hack/get-build.sh) to or use as a reference on how to get the most recent builds with curl. With `get-build.sh` you can grab the most recent stable build, the most recent release candidate, or the most recent build to pass our ci and gce e2e tests (essentially a nightly build).
```console
usage:
./hack/get-build.sh [stable|release|latest|latest-green]
Run `./hack/get-build.sh -h` for its usage.
stable: latest stable version
release: latest release candidate
latest: latest ci build
latest-green: latest ci build to pass gce e2e
For example, to get a build at a specific version (v1.0.2):
```console
./hack/get-build.sh v1.0.2
```
You can also use the gsutil tool to explore the Google Cloud Storage release bucket. Here are some examples:
Alternatively, to get the latest stable release:
```console
./hack/get-build.sh release/stable
```
Finally, you can just print the latest or stable version:
```console
./hack/get-build.sh -v ci/latest
```
You can also use the gsutil tool to explore the Google Cloud Storage release buckets. Here are some examples:
```sh
gsutil cat gs://kubernetes-release/ci/latest.txt # output the latest ci version number

View File

@ -18,53 +18,59 @@ set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/cluster/common.sh"
declare -r KUBE_RELEASE_BUCKET_URL="https://storage.googleapis.com/kubernetes-release"
declare -r KUBE_TAR_NAME="kubernetes.tar.gz"
usage() {
echo "usage:
$0 [stable|release|latest|latest-green]
stable: latest stable version
release: latest release candidate
latest: latest ci build
latest-green: latest ci build to pass gce e2e"
echo "${0} [-v] <version number or publication>"
echo " -v: Don't get tars, just print the version number"
echo ""
echo ' Version number or publication is either a proper version number'
echo ' (e.g. "v1.0.6", "v1.2.0-alpha.1.881+376438b69c7612") or a version'
echo ' publication of the form <bucket>/<version> (e.g. "release/stable",'
echo ' "ci/latest-1"). Some common ones are:'
echo ' - "release/stable"'
echo ' - "release/latest"'
echo ' - "ci/latest"'
echo ' See the docs on getting builds for more information about version'
echo ' publication.'
}
print_version=false
while getopts ":vh" opt; do
case ${opt} in
v)
print_version="true"
;;
h)
usage
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
esac
done
shift $((OPTIND-1))
if [[ $# -ne 1 ]]; then
usage
exit 1
fi
case "$1" in
"latest")
# latest ci version is written in the latest.txt in the /ci dir
KUBE_TAR_RELATIVE_PATH="ci"
KUBE_VERSION_FILE="latest.txt"
;;
"latest-green")
# latest ci version to pass gce e2e is written in the latest-green.txt in the /ci dir
KUBE_TAR_RELATIVE_PATH="ci"
KUBE_VERSION_FILE="latest-green.txt"
;;
"stable")
# latest stable release version is written in the stable.txt file in the /release dir
KUBE_TAR_RELATIVE_PATH="release"
KUBE_VERSION_FILE="stable.txt"
;;
"release")
# latest release candidate version is written in latest.txt in the /release dir
KUBE_TAR_RELATIVE_PATH="release"
KUBE_VERSION_FILE="latest.txt"
;;
*)
usage
exit 1
;;
esac
set_binary_version ${1}
KUBE_BINARY_DIRECTORY="${KUBE_RELEASE_BUCKET_URL}/${KUBE_TAR_RELATIVE_PATH}"
KUBE_VERSION=$(curl --silent --fail "${KUBE_BINARY_DIRECTORY}/${KUBE_VERSION_FILE}")
KUBE_BINARY_PATH="${KUBE_BINARY_DIRECTORY}/${KUBE_VERSION}/${KUBE_TAR_NAME}"
curl --fail -o kubernetes-${KUBE_VERSION}.tar.gz "${KUBE_BINARY_PATH}"
if [[ "${print_version}" == "true" ]]; then
echo "${KUBE_VERSION}"
else
echo "Using version at ${1}: ${KUBE_VERSION}" >&2
tars_from_version
curl --fail -o kubernetes-${KUBE_VERSION}.tar.gz "${KUBE_TAR_URL}"
fi

View File

@ -20,7 +20,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"os/exec"
@ -45,59 +44,14 @@ const (
versionURLFmt = "https://storage.googleapis.com/kubernetes-release/%s/%s.txt"
)
// realVersion turns a version constant s--one accepted by cluster/gce/upgrade.sh--
// into a deployable version string. If the s is not known to be a version
// constant, it will assume it is already a valid version, and return s directly.
//
// NOTE: KEEP THIS LIST UP-TO-DATE WITH THE CODE BELOW.
// The version strings supported are:
// - "latest_stable" (returns a string like "0.18.2")
// - "latest_release" (returns a string like "0.19.1")
// - "latest_ci" (returns a string like "0.19.1-669-gabac8c8")
// realVersion turns a version constant s into a version string deployable on
// GKE. See hack/get-build.sh for more information.
func realVersion(s string) (string, error) {
bucket, file := "", ""
switch s {
// NOTE: IF YOU CHANGE THE FOLLOWING LIST, ALSO UPDATE cluster/gce/upgrade.sh
case "latest_stable":
bucket, file = "release", "stable"
case "latest_release":
bucket, file = "release", "latest"
case "latest_ci":
bucket, file = "ci", "latest"
default:
// If we don't match one of the above, we assume that the passed version
// is already valid (such as "0.19.1" or "0.19.1-669-gabac8c8").
Logf("Assuming %q is already a valid version.", s)
return s, nil
v, _, err := runCmd(path.Join(testContext.RepoRoot, "hack/get-build.sh"), "-v", s)
if err != nil {
return v, err
}
url := fmt.Sprintf(versionURLFmt, bucket, file)
var v string
Logf("Fetching version from %s", url)
c := &http.Client{Timeout: 2 * time.Second}
if err := wait.Poll(poll, singleCallTimeout, func() (bool, error) {
r, err := c.Get(url)
if err != nil {
Logf("Error reaching %s: %v", url, err)
return false, nil
}
if r.StatusCode != http.StatusOK {
Logf("Bad response; status: %d, response: %v", r.StatusCode, r)
return false, nil
}
defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
if err != nil {
Logf("Could not read response body: %v", err)
return false, nil
}
v = strings.TrimSpace(string(b))
return true, nil
}); err != nil {
return "", fmt.Errorf("failed to fetch real version from %s", url)
}
// Versions start with "v", so remove that.
return strings.TrimPrefix(v, "v"), nil
return strings.TrimPrefix(strings.TrimSpace(v), "v"), nil
}
// The following upgrade functions are passed into the framework below and used
@ -207,7 +161,7 @@ var _ = Describe("Skipped", func() {
var err error
v, err = realVersion(testContext.UpgradeTarget)
expectNoError(err)
Logf("Version for %q is %s", testContext.UpgradeTarget, v)
Logf("Version for %q is %q", testContext.UpgradeTarget, v)
By("Setting up the service, RC, and pods")
f.beforeEach()

View File

@ -79,7 +79,7 @@ func init() {
flag.StringVar(&cloudConfig.ClusterTag, "cluster-tag", "", "Tag used to identify resources. Only required if provider is aws.")
flag.IntVar(&testContext.MinStartupPods, "minStartupPods", 0, "The number of pods which we need to see in 'Running' state with a 'Ready' condition of true, before we try running tests. This is useful in any cluster which needs some base pod-based services running before it can be used.")
flag.StringVar(&testContext.UpgradeTarget, "upgrade-target", "latest_ci", "Version to upgrade to (e.g. 'latest_stable', 'latest_release', 'latest_ci', '0.19.1', '0.19.1-669-gabac8c8') if doing an upgrade test.")
flag.StringVar(&testContext.UpgradeTarget, "upgrade-target", "ci/latest", "Version to upgrade to (e.g. 'release/stable', 'release/latest', 'ci/latest', '0.19.1', '0.19.1-669-gabac8c8') if doing an upgrade test.")
flag.StringVar(&testContext.PrometheusPushGateway, "prom-push-gateway", "", "The URL to prometheus gateway, so that metrics can be pushed during e2es and scraped by prometheus. Typically something like 127.0.0.1:9091.")
flag.BoolVar(&testContext.VerifyServiceAccount, "e2e-verify-service-account", true, "If true tests will verify the service account before running.")
}