-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for GCI QA jobs #29631
Add support for GCI QA jobs #29631
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,13 +121,6 @@ function unpack_binaries() { | |
tar -xzf kubernetes-test.tar.gz | ||
} | ||
|
||
# Get the latest GCI image in a family. | ||
function get_latest_gci_image() { | ||
local -r image_project="$1" | ||
local -r image_family="$2" | ||
echo "$(gcloud compute images describe-from-family ${image_family} --project=${image_project} --format='value(name)')" | ||
} | ||
|
||
function get_latest_docker_release() { | ||
# Typical Docker release versions are like v1.11.2-rc1, v1.11.2, and etc. | ||
local -r version_re='.*\"tag_name\":[[:space:]]+\"v([0-9\.r|c-]+)\",.*' | ||
|
@@ -186,6 +179,37 @@ function dump_cluster_logs() { | |
fi | ||
} | ||
|
||
# GCI specific settings. | ||
# Assumes: JENKINS_GCI_IMAGE_FAMILY | ||
function setup_gci_vars() { | ||
local -r gci_staging_project=container-vm-image-staging | ||
local -r image_info="$(gcloud compute images describe-from-family ${JENKINS_GCI_IMAGE_FAMILY} --project=${gci_staging_project} --format=json)" | ||
local -r image_description="$(echo ${image_info} | jq '.description')" | ||
local -r image_name="$(echo ${image_info} | jq '.name')" | ||
|
||
if [[ "${JENKINS_USE_GCI_VERSION:-}" =~ ^[yY]$ ]]; then | ||
# GCI QA jobs use the builtin k8s version. | ||
# Staged GCI images all include versions in their image descriptions so we | ||
# extract builtin Kubernetes version from them. | ||
local -r k8s_version_re='.*Kubernetes: ([0-9a-z.-]+),.*' | ||
if [[ ${image_description} =~ ${k8s_version_re} ]]; then | ||
export JENKINS_PUBLISHED_VERSION="release/${BASH_REMATCH[1]}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this environment variable used for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's used to determine which version of k8s to download, and to use in test. https://github.com/kubernetes/kubernetes/blob/master/hack/jenkins/e2e-runner.sh#L285 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO the image description is not the most reliable source to determine K8s version installed on the image. Did you have any other options in mind? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I actually had a more reliable way implemented before I sent this PR On Jul 27, 2016 5:10 PM, "Amey Deshpande" notifications@github.com wrote:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you have an alternative in the works, I'm fine with the current version as an interim solution. |
||
else | ||
echo "Failed to determine builtin k8s version for image ${image_name}: ${image_description}" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
export KUBE_GCE_MASTER_PROJECT="${gci_staging_project}" | ||
export KUBE_GCE_MASTER_IMAGE="${image_name}" | ||
export KUBE_MASTER_OS_DISTRIBUTION="gci" | ||
if [[ "${JENKINS_GCI_IMAGE_FAMILY}" == "gci-canary-test" ]]; then | ||
# The family "gci-canary-test" is reserved for a special type of GCI images | ||
# that are used to continuously validate Docker releases. | ||
export KUBE_GCI_DOCKER_VERSION="$(get_latest_docker_release)" | ||
fi | ||
} | ||
|
||
### Pre Set Up ### | ||
if running_in_docker; then | ||
record_command "${STAGE_PRE}" "download_gcloud" curl -fsSL --retry 3 --keepalive-time 2 -o "${WORKSPACE}/google-cloud-sdk.tar.gz" 'https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz' | ||
|
@@ -215,17 +239,9 @@ if [[ -n "${CLOUDSDK_BUCKET:-}" ]]; then | |
export CLOUDSDK_CONFIG=/var/lib/jenkins/.config/gcloud | ||
fi | ||
|
||
# We get the image project and name for GCI dynamically. | ||
# GCI specific settings. | ||
if [[ -n "${JENKINS_GCI_IMAGE_FAMILY:-}" ]]; then | ||
GCI_STAGING_PROJECT=container-vm-image-staging | ||
export KUBE_GCE_MASTER_PROJECT="${GCI_STAGING_PROJECT}" | ||
export KUBE_GCE_MASTER_IMAGE="$(get_latest_gci_image "${GCI_STAGING_PROJECT}" "${JENKINS_GCI_IMAGE_FAMILY}")" | ||
export KUBE_MASTER_OS_DISTRIBUTION="gci" | ||
if [[ "${JENKINS_GCI_IMAGE_FAMILY}" == "gci-canary-test" ]]; then | ||
# The family "gci-canary-test" is reserved for a special type of GCI images | ||
# that are used to continuously validate Docker releases. | ||
export KUBE_GCI_DOCKER_VERSION="$(get_latest_docker_release)" | ||
fi | ||
setup_gci_vars | ||
fi | ||
|
||
if [[ -f "${KUBEKINS_SERVICE_ACCOUNT_FILE:-}" ]]; then | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not check for exact match instead of regex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this way it allows both cases? For some reason this has been a convention in k8s' code