Skip to content

Commit daaaa19

Browse files
committed
default KUBERNETES_VERSION if not set
1 parent 3930054 commit daaaa19

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

scripts/ci-e2e-lib.sh

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,41 @@ capi:buildDockerImages () {
3434
fi
3535
}
3636

37+
# k8s::prepareKindestImagesVariables defaults the environment variables KUBERNETES_VERSION,
38+
# KUBERNETES_VERSION_UPGRADE_TO and KUBERNETES_VERSION_LATEST_CI depending on what
39+
# is set in GINKGO_FOCUS.
40+
# Note: We do this to ensure that the kindest/node image gets built if it does
41+
# not already exist, e.g. for pre-releases, but only if necessary.
42+
k8s::prepareKindestImagesVariables() {
43+
# Always default KUBERNETES_VERSION to the value in the e2e config.
44+
45+
if [[ ${GINKGO_FOCUS:-} == *"K8s-Install-ci-latest"* ]]; then
46+
# If the test focuses on [K8s-Install-ci-latest], only default KUBERNETES_VERSION_LATEST_CI
47+
# to the value in the e2e config and only if it is not set.
48+
# Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
49+
if [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
50+
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
51+
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
52+
fi
53+
elif [[ ${GINKGO_FOCUS:-} != *"K8s-Upgrade"* ]]; then
54+
# In any other case which is not [K8s-Upgrade], default KUBERNETES_VERSION if it is not set to make sure
55+
# the corresponding kindest/node image exists.
56+
if [[ -z "${KUBERNETES_VERSION:-}" ]]; then
57+
KUBERNETES_VERSION=$(grep KUBERNETES_VERSION: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
58+
echo "Defaulting KUBERNETES_VERSION to ${KUBERNETES_VERSION} to trigger image build (because env var is not set)"
59+
fi
60+
61+
# Tests not focusing on [PR-Blocking] or [K8s-Install], also run upgrade tests so default
62+
# KUBERNETES_VERSION_UPGRADE_TO to the value in the e2e config if it is not set.
63+
if [[ ${GINKGO_FOCUS:-} != *"PR-Blocking"* ]] && [[ ${GINKGO_FOCUS:-} != *"K8s-Install"* ]]; then
64+
if [[ -z "${KUBERNETES_VERSION_UPGRADE_TO:-}" ]]; then
65+
KUBERNETES_VERSION_UPGRADE_TO=$(grep KUBERNETES_VERSION_UPGRADE_TO: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
66+
echo "Defaulting KUBERNETES_VERSION_UPGRADE_TO to ${KUBERNETES_VERSION_UPGRADE_TO} to trigger image build (because env var is not set)"
67+
fi
68+
fi
69+
fi
70+
}
71+
3772
# k8s::prepareKindestImages checks all the e2e test variables representing a Kubernetes version,
3873
# and makes sure a corresponding kindest/node image is available locally.
3974
k8s::prepareKindestImages() {
@@ -65,15 +100,6 @@ k8s::prepareKindestImages() {
65100
kind::prepareKindestImage "$resolveVersion"
66101
fi
67102

68-
# If the test focuses on [K8s-Install-ci-latest], default KUBERNETES_VERSION_LATEST_CI
69-
# to the value in the e2e config if it is not set.
70-
# Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
71-
if [[ ${GINKGO_FOCUS:-} == *"K8s-Install-ci-latest"* ]]; then
72-
if [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
73-
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
74-
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
75-
fi
76-
fi
77103
if [ -n "${KUBERNETES_VERSION_LATEST_CI:-}" ]; then
78104
k8s::resolveVersion "KUBERNETES_VERSION_LATEST_CI" "$KUBERNETES_VERSION_LATEST_CI"
79105
export KUBERNETES_VERSION_LATEST_CI=$resolveVersion

scripts/ci-e2e.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export USE_EXISTING_CLUSTER=false
5454
# - KUBERNETES_VERSION_UPGRADE_TO
5555
# - KUBERNETES_VERSION_UPGRADE_FROM
5656
# - KUBERNETES_VERSION_LATEST_CI
57+
k8s::prepareKindestImagesVariables
5758
k8s::prepareKindestImages
5859

5960
# pre-pull all the images that will be used in the e2e, thus making the actual test run

test/e2e/config/docker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ variables:
314314
# allowing the same e2e config file to be re-used in different Prow jobs e.g. each one with a K8s version permutation.
315315
# The following Kubernetes versions should be the latest versions with already published kindest/node images.
316316
# This avoids building node images in the default case which improves the test duration significantly.
317-
KUBERNETES_VERSION_MANAGEMENT: "v1.30.0-rc.1"
317+
KUBERNETES_VERSION_MANAGEMENT: "v1.29.2"
318318
KUBERNETES_VERSION: "v1.30.0-rc.1"
319319
KUBERNETES_VERSION_UPGRADE_FROM: "v1.29.2"
320320
KUBERNETES_VERSION_UPGRADE_TO: "v1.30.0-rc.1"

0 commit comments

Comments
 (0)