Skip to content

Commit

Permalink
add version resolve and enable windows conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
Cecile Robert-Michon committed Oct 26, 2021
1 parent ad92ba2 commit 662310f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
39 changes: 39 additions & 0 deletions hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,42 @@ capz::util::should_build_kubernetes() {
fi
echo "false"
}

capz::util::resolve_k8s_versions() {
if [ -n "${KUBERNETES_VERSION:-}" ]; then
k8s::resolveVersion "KUBERNETES_VERSION" "$KUBERNETES_VERSION"
export KUBERNETES_VERSION=$resolveVersion
fi

if [ -n "${KUBERNETES_VERSION_UPGRADE_TO:-}" ]; then
k8s::resolveVersion "KUBERNETES_VERSION_UPGRADE_TO" "$KUBERNETES_VERSION_UPGRADE_TO"
export KUBERNETES_VERSION_UPGRADE_TO=$resolveVersion
fi

if [ -n "${KUBERNETES_VERSION_UPGRADE_FROM:-}" ]; then
k8s::resolveVersion "KUBERNETES_VERSION_UPGRADE_FROM" "$KUBERNETES_VERSION_UPGRADE_FROM"
export KUBERNETES_VERSION_UPGRADE_FROM=$resolveVersion
fi
}

# k8s::resolveVersion resolves kubernetes version labels (e.g. latest) to the corresponding version numbers.
# The result will be available in the resolveVersion variable which is accessible from the caller.
#
# NOTE: this doesn't guarantee a reference VM image will be available for this version.
# TODO: check the capi offer for the image.
k8s::resolveVersion() {
local variableName=$1
local version=$2

resolveVersion=$version
if [[ "$version" =~ ^v ]]; then
return
fi

if [[ "$version" =~ ^ci/ ]]; then
resolveVersion=$(curl -LsS "http://dl.k8s.io/ci/${version#ci/}.txt")
else
resolveVersion=$(curl -LsS "http://dl.k8s.io/release/${version}.txt")
fi
echo "+ $variableName=\"$version\" resolved to \"$resolveVersion\""
}
2 changes: 2 additions & 0 deletions scripts/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export AZURE_CONTROL_PLANE_MACHINE_TYPE="${AZURE_CONTROL_PLANE_MACHINE_TYPE:-"St
export AZURE_NODE_MACHINE_TYPE="${AZURE_NODE_MACHINE_TYPE:-"Standard_D2s_v3"}"
export KIND_EXPERIMENTAL_DOCKER_NETWORK="bridge"

capz::util::resolve_k8s_versions

# Generate SSH key.
AZURE_SSH_PUBLIC_KEY_FILE=${AZURE_SSH_PUBLIC_KEY_FILE:-""}
if [ -z "${AZURE_SSH_PUBLIC_KEY_FILE}" ]; then
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/capi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"os"

"github.com/blang/semver"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -228,6 +229,12 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
})

var _ = Describe("When upgrading a workload cluster and testing K8S conformance [Conformance] [K8s-Upgrade]", func() {
// Opt into Windows for versions greater than or equal to 1.22
if semver.MustParse(e2eConfig.Variables[capi_e2e.KubernetesVersionUpgradeFrom]).GTE(semver.MustParse("v1.22.0")) {
Expect(os.Setenv("WINDOWS_WORKER_MACHINE_COUNT", "2")).To(Succeed())
Expect(os.Setenv("K8S_FEATURE_GATES", "WindowsHostProcessContainers=true")).To(Succeed())
}

capi_e2e.ClusterUpgradeConformanceSpec(context.TODO(), func() capi_e2e.ClusterUpgradeConformanceSpecInput {
return capi_e2e.ClusterUpgradeConformanceSpecInput{
E2EConfig: e2eConfig,
Expand Down

0 comments on commit 662310f

Please sign in to comment.