Skip to content
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

🌱 CI: default building kind node-images depending on KIND_BUILD_IMAGES env variable instead of ginkgo magic regexes #11784

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 18 additions & 35 deletions scripts/ci-e2e-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,51 +40,34 @@ capi:buildDockerImages () {
# Note: We do this to ensure that the kindest/node image gets built if it does
# not already exist, e.g. for pre-releases, but only if necessary.
k8s::prepareKindestImagesVariables() {
KIND_BUILD_IMAGES="${KIND_BUILD_IMAGES:-}"

# Always default KUBERNETES_VERSION_MANAGEMENT because we always create a management cluster out of it.
if [[ -z "${KUBERNETES_VERSION_MANAGEMENT:-}" ]]; then
KUBERNETES_VERSION_MANAGEMENT=$(grep KUBERNETES_VERSION_MANAGEMENT: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
echo "Defaulting KUBERNETES_VERSION_MANAGEMENT to ${KUBERNETES_VERSION_MANAGEMENT} to trigger image build (because env var is not set)"
fi

if [[ ${GINKGO_FOCUS:-} == *"K8s-Install-ci-latest"* ]]; then
# If the test focuses on [K8s-Install-ci-latest], only default KUBERNETES_VERSION_LATEST_CI
# to the value in the e2e config and only if it is not set.
# Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
if [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
fi
elif [[ ${GINKGO_FOCUS:-} != *"K8s-Upgrade"* ]]; then
# In any other case which is not [K8s-Upgrade], default KUBERNETES_VERSION if it is not set to make sure
# the corresponding kindest/node image exists.
if [[ -z "${KUBERNETES_VERSION:-}" ]]; then
KUBERNETES_VERSION=$(grep KUBERNETES_VERSION: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
echo "Defaulting KUBERNETES_VERSION to ${KUBERNETES_VERSION} to trigger image build (because env var is not set)"
fi
# Default KUBERNETES_VERSION, KUBERNETES_VERSION_LATEST_CI, KUBERNETES_VERSION_UPGRADE_TO or KUBERNETES_VERSION_UPGRADE_FROM if set in KIND_BUILD_IMAGES var.

if [[ ",${KIND_BUILD_IMAGES}," == *",KUBERNETES_VERSION,"* ]] && [[ -z "${KUBERNETES_VERSION:-}" ]]; then
KUBERNETES_VERSION=$(grep KUBERNETES_VERSION: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
echo "Defaulting KUBERNETES_VERSION to ${KUBERNETES_VERSION} to trigger image build (because env var is not set)"
fi

# Tests not focusing on anything and skipping [Conformance] run a clusterctl upgrade test
# on the latest kubernetes version as management cluster.
if [[ ${GINKGO_FOCUS:-} == "" ]] && [[ ${GINKGO_SKIP} == *"Conformance"* ]]; then
# Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
if [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
fi
if [[ ",${KIND_BUILD_IMAGES}," == *",KUBERNETES_VERSION_LATEST_CI,"* ]] && [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
fi

# Tests not focusing on [PR-Blocking], [K8s-Install] or [K8s-Install-ci-latest],
# also run upgrade tests so default KUBERNETES_VERSION_UPGRADE_TO and KUBERNETES_VERSION_UPGRADE_FROM
# to the value in the e2e config if they are not set.
if [[ ${GINKGO_FOCUS:-} != *"PR-Blocking"* ]] && [[ ${GINKGO_FOCUS:-} != *"K8s-Install"* ]]; then
if [[ -z "${KUBERNETES_VERSION_UPGRADE_TO:-}" ]]; then
KUBERNETES_VERSION_UPGRADE_TO=$(grep KUBERNETES_VERSION_UPGRADE_TO: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
echo "Defaulting KUBERNETES_VERSION_UPGRADE_TO to ${KUBERNETES_VERSION_UPGRADE_TO} to trigger image build (because env var is not set)"
fi
if [[ -z "${KUBERNETES_VERSION_UPGRADE_FROM:-}" ]]; then
KUBERNETES_VERSION_UPGRADE_FROM=$(grep KUBERNETES_VERSION_UPGRADE_FROM: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
echo "Defaulting KUBERNETES_VERSION_UPGRADE_FROM to ${KUBERNETES_VERSION_UPGRADE_FROM} to trigger image build (because env var is not set)"
fi
if [[ ",${KIND_BUILD_IMAGES}," == *",KUBERNETES_VERSION_UPGRADE_TO,"* ]] && [[ -z "${KUBERNETES_VERSION_UPGRADE_TO:-}" ]]; then
KUBERNETES_VERSION_UPGRADE_TO=$(grep KUBERNETES_VERSION_UPGRADE_TO: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
echo "Defaulting KUBERNETES_VERSION_UPGRADE_TO to ${KUBERNETES_VERSION_UPGRADE_TO} to trigger image build (because env var is not set)"
fi

if [[ ",${KIND_BUILD_IMAGES}," == *",KUBERNETES_VERSION_UPGRADE_FROM,"* ]] && [[ -z "${KUBERNETES_VERSION_UPGRADE_FROM:-}" ]]; then
KUBERNETES_VERSION_UPGRADE_FROM=$(grep KUBERNETES_VERSION_UPGRADE_FROM: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
echo "Defaulting KUBERNETES_VERSION_UPGRADE_FROM to ${KUBERNETES_VERSION_UPGRADE_FROM} to trigger image build (because env var is not set)"
fi
}

Expand Down