Skip to content

Commit 40f1a33

Browse files
committed
Add CI image to target cluster for clusterctl upgrade tests
1 parent ef60cd0 commit 40f1a33

File tree

7 files changed

+96
-5
lines changed

7 files changed

+96
-5
lines changed

scripts/ci-e2e.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# limitations under the License.
1616

1717
################################################################################
18-
# usage: ci-conformance.sh
19-
# This program runs the clusterctl conformance e2e tests.
18+
# usage: ci-e2e.sh
19+
# This program runs the e2e tests.
2020
################################################################################
2121

2222
set -x
@@ -84,6 +84,20 @@ fi
8484

8585
"hack/ci/create_devstack.sh"
8686

87+
# Upload image for e2e clusterctl upgrade tests
88+
source "${REPO_ROOT}/hack/ci/${RESOURCE_TYPE}.sh"
89+
CONTAINER_ARCHIVE="${ARTIFACTS}/capo-e2e-image.tar"
90+
SSH_KEY="$(get_ssh_private_key_file)"
91+
SSH_ARGS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o PasswordAuthentication=no"
92+
CONTROLLER_IP=${CONTROLLER_IP:-"10.0.3.15"}
93+
94+
make e2e-image
95+
docker save -o "${CONTAINER_ARCHIVE}" gcr.io/k8s-staging-capi-openstack/capi-openstack-controller:e2e
96+
scp -i "${SSH_KEY}" ${SSH_ARGS} "${CONTAINER_ARCHIVE}" "cloud@${CONTROLLER_IP}:capo-e2e-image.tar"
97+
ssh -i "${SSH_KEY}" ${SSH_ARGS} "cloud@${CONTROLLER_IP}" -- sudo chown root:root capo-e2e-image.tar
98+
ssh -i "${SSH_KEY}" ${SSH_ARGS} "cloud@${CONTROLLER_IP}" -- sudo chmod u=rw,g=r,o=r capo-e2e-image.tar
99+
ssh -i "${SSH_KEY}" ${SSH_ARGS} "cloud@${CONTROLLER_IP}" -- sudo mv capo-e2e-image.tar /var/www/html/capo-e2e-image.tar
100+
87101
export OPENSTACK_CLOUD_YAML_FILE
88102
OPENSTACK_CLOUD_YAML_FILE="$(pwd)/clouds.yaml"
89103
make test-e2e

test/e2e/data/e2e_conf.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ providers:
100100
- sourcePath: "./infrastructure-openstack/cluster-template-external-cloud-provider.yaml"
101101
- sourcePath: "./infrastructure-openstack/cluster-template-without-lb.yaml"
102102
replacements:
103-
# TODO: We should use e2e here instead of main, but we need a way to get it into the workload cluster
104-
# for upgrade tests for that to work.
105103
- old: gcr.io/k8s-staging-capi-openstack/capi-openstack-controller:dev
106-
new: gcr.io/k8s-staging-capi-openstack/capi-openstack-controller:main
104+
new: gcr.io/k8s-staging-capi-openstack/capi-openstack-controller:e2e
107105
- old: "imagePullPolicy: Always"
108106
new: "imagePullPolicy: IfNotPresent"
109107
- old: "--v=2"

test/e2e/data/kustomize/default/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ resources:
44

55
components:
66
- ../common-patches
7+
- ../upgrade-patches
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# Workaround for https://github.com/kubernetes-sigs/cluster-api/issues/7457
3+
# There is a small but important difference between these two:
4+
# path: /a/b/c
5+
# *creates* the c array, overwriting anything that was there before
6+
# path: /a/b/c/-
7+
# *adds* to the c array and does not work if the array is missing
8+
#
9+
# We add to the postKubeadmCommands (instead of pre*) since we need the CI artifacts
10+
# script to run first. Without this, the container images are not imported properly.
11+
- op: add
12+
path: /spec/kubeadmConfigSpec/postKubeadmCommands
13+
value:
14+
- /usr/local/bin/ci-artifacts-openstack.sh
15+
- op: add
16+
path: /spec/kubeadmConfigSpec/files/-
17+
value:
18+
content: |
19+
#!/bin/bash
20+
DOWNLOAD_E2E_IMAGE=${DOWNLOAD_E2E_IMAGE:=false}
21+
if [ ! "${DOWNLOAD_E2E_IMAGE}" = true ]; then
22+
echo "Not downloading E2E image, exiting"
23+
exit 0
24+
fi
25+
# Download the locally built CAPO controller image
26+
echo "Downloading ${E2E_IMAGE_URL}"
27+
wget "${E2E_IMAGE_URL}" -O "/tmp/capo-controller-manager.tar"
28+
sudo ctr -n k8s.io images import "/tmp/capo-controller-manager.tar" || echo "* ignoring expected 'ctr images import' result"
29+
owner: root:root
30+
path: /usr/local/bin/ci-artifacts-openstack.sh
31+
permissions: "0750"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# Workaround for https://github.com/kubernetes-sigs/cluster-api/issues/7457
3+
# There is a small but important difference between these two:
4+
# path: /a/b/c
5+
# *creates* the c array, overwriting anything that was there before
6+
# path: /a/b/c/-
7+
# *adds* to the c array and does not work if the array is missing
8+
#
9+
# We add to the postKubeadmCommands (instead of pre*) since we need the CI artifacts
10+
# script to run first. Without this, the container images are not imported properly.
11+
- op: add
12+
path: /spec/template/spec/postKubeadmCommands
13+
value:
14+
- /usr/local/bin/ci-artifacts-openstack.sh
15+
- op: add
16+
path: /spec/template/spec/files/-
17+
value:
18+
content: |
19+
#!/bin/bash
20+
DOWNLOAD_E2E_IMAGE=${DOWNLOAD_E2E_IMAGE:=false}
21+
if [ ! "${DOWNLOAD_E2E_IMAGE}" = true ]; then
22+
echo "Not downloading E2E image, exiting"
23+
exit 0
24+
fi
25+
# Download the locally built CAPO controller image
26+
echo "Downloading ${E2E_IMAGE_URL}"
27+
wget "${E2E_IMAGE_URL}" -O "/tmp/capo-controller-manager.tar"
28+
sudo ctr -n k8s.io images import "/tmp/capo-controller-manager.tar" || echo "* ignoring expected 'ctr images import' result"
29+
owner: root:root
30+
path: /usr/local/bin/ci-artifacts-openstack.sh
31+
permissions: "0750"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Modifications to release templates for clusterctl upgrade scenarios
2+
---
3+
apiVersion: kustomize.config.k8s.io/v1alpha1
4+
kind: Component
5+
6+
patches:
7+
- target:
8+
kind: KubeadmControlPlane
9+
name: \${CLUSTER_NAME}-control-plane
10+
path: ci-hack-kcp.yaml
11+
- target:
12+
kind: KubeadmConfigTemplate
13+
name: \${CLUSTER_NAME}-md-0
14+
path: ci-hack-kct.yaml

test/e2e/suites/e2e/clusterctl_upgrade_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import (
3636
var _ = Describe("When testing clusterctl upgrades (v0.6=>current) [clusterctl-upgrade]", func() {
3737
ctx := context.TODO()
3838
shared.SetEnvVar("USE_CI_ARTIFACTS", "true", false)
39+
shared.SetEnvVar("DOWNLOAD_E2E_IMAGE", "true", false)
40+
shared.SetEnvVar("E2E_IMAGE_URL", "http://10.0.3.15/capo-e2e-image.tar", false)
3941

4042
capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput {
4143
return capi_e2e.ClusterctlUpgradeSpecInput{

0 commit comments

Comments
 (0)