Skip to content

Commit a39a9ab

Browse files
authored
Adding an operator-upgrade Github workflow. (#716)
This test will ensure the bundle built in the PR can be used to upgrade from the last bundle available of KMM. Signed-off-by: Yoni Bettan <[email protected]>
1 parent 32fdc1a commit a39a9ab

File tree

3 files changed

+124
-0
lines changed

3 files changed

+124
-0
lines changed

.github/workflows/e2e.yaml

+68
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,71 @@ jobs:
183183
if: ${{ always() }}
184184
with:
185185
output-file: ${{ matrix.name }}-support-bundle.tar.gz
186+
187+
188+
operator-upgrade:
189+
190+
runs-on: ubuntu-20.04
191+
name: operator-upgrade
192+
needs: [build-operator-image, build-signing-image, build-worker-image]
193+
194+
services:
195+
registry:
196+
image: registry:2
197+
ports: ['5000:5000/tcp']
198+
199+
steps:
200+
201+
- name: Checkout
202+
uses: actions/checkout@v4
203+
204+
- name: Create the minikube cluster
205+
uses: ./.github/actions/create-minikube-cluster
206+
with:
207+
start-args: --insecure-registry=host.minikube.internal:5000
208+
209+
- name: Download container images
210+
uses: actions/download-artifact@v4
211+
with:
212+
path: artifacts
213+
214+
- name: Copy kmm, signing and worker images to the registry
215+
run: |
216+
# KMM is pulled by operator-sdk in the cluster and not by minikube
217+
docker load -i artifacts/ci-image-kmm/kmm_local.tar
218+
docker load -i artifacts/ci-image-signer/kmm-signimage_local.tar
219+
docker load -i artifacts/ci-image-worker/kmm-worker_local.tar
220+
221+
docker tag kmm:local localhost:5000/kmm/kmm:local
222+
docker tag kmm-signimage:local localhost:5000/kmm/signimage:local
223+
docker tag kmm-worker:local localhost:5000/kmm/worker:local
224+
225+
docker push localhost:5000/kmm/kmm:local
226+
docker push localhost:5000/kmm/signimage:local
227+
docker push localhost:5000/kmm/worker:local
228+
229+
- name: Set some Ubuntu environment variables
230+
run: |
231+
grep 'ID=' /etc/os-release >> "$GITHUB_ENV"
232+
grep 'VERSION_ID=' /etc/os-release >> "$GITHUB_ENV"
233+
234+
- name: Cache binaries needed by Makefile
235+
id: cache-bin
236+
uses: actions/cache@v4
237+
with:
238+
path: ./bin
239+
key: ${{ runner.os }}-${{ env.ID }}-${{ env.VERSION_ID }}-bin-${{ env.GO_VERSION }}-${{ hashFiles('Makefile') }}
240+
241+
- uses: actions/setup-go@v5
242+
with:
243+
go-version: ${{ env.GO_VERSION }}
244+
if: steps.cache-bin.outputs.cache-hit != 'true'
245+
246+
- name: Run test
247+
run: ./ci/prow/operator-upgrade
248+
249+
- name: Collect troubleshooting data
250+
uses: ./.github/actions/collect-troubleshooting
251+
if: ${{ always() }}
252+
with:
253+
output-file: operator-upgrade-support-bundle.tar.gz

ci/prow/operator-upgrade

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
# operator-sdk run bundle<-upgrade> doesn't support local images and the image
6+
# has to be pushed to a remote registry.
7+
# When the command is run, operator-sdk checks the image twice. At first, it
8+
# validates that the image exists and then it creates a pod in the cluster
9+
# deploying the image, therefore, the image has to be accessed from both, the
10+
# running host and the minikube cluster.
11+
sudo echo "127.0.0.1 host.minikube.internal" | sudo tee -a /etc/hosts
12+
13+
# Build the bundle from the 'main' branch
14+
git fetch origin
15+
git checkout -b main origin/main
16+
make bundle bundle-build bundle-push \
17+
VERSION="1.0.0" \
18+
BUNDLE_IMG=localhost:5000/kmm/kmm-bundle:current
19+
# go back to the last branch
20+
git checkout -
21+
22+
# Install OLM
23+
make operator-sdk
24+
./bin/operator-sdk olm install
25+
26+
# It takes some time to the operatorhubio-catalog catalogsource to get to a
27+
# READY connection state, we need this to validate that the catalog is ready
28+
# before installing a bundle, otherwise we might get a race condition that will
29+
# resolved in the Subscription not being reconciled after the connecting is
30+
# ready
31+
timeout 3m bash -c 'until [ "$(kubectl -n olm get catalogsource/operatorhubio-catalog -o jsonpath={.status.connectionState.lastObservedState})" = "READY" ]; do sleep 5; done'
32+
33+
# Deploy the current bundle
34+
./bin/operator-sdk run bundle host.minikube.internal:5000/kmm/kmm-bundle:current \
35+
--namespace operators \
36+
--use-http
37+
38+
# Build the new bundle
39+
make bundle bundle-build bundle-push \
40+
VERSION="2.0.0" \
41+
IMG=host.minikube.internal:5000/kmm/kmm:local \
42+
SIGNER_IMG=host.minikube.internal:5000/kmm/signimage:local \
43+
WORKER_IMG=host.minikube.internal:5000/kmm/worker:local \
44+
BUNDLE_IMG=localhost:5000/kmm/kmm-bundle:local
45+
46+
# Upgrade to the new bundle
47+
./bin/operator-sdk run bundle-upgrade host.minikube.internal:5000/kmm/kmm-bundle:local \
48+
--namespace operators \
49+
--use-http
50+

support/kmm.spec.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ spec:
1010
- default
1111
- cert-manager
1212
- kmm-operator-system
13+
- olm
14+
- operators
1315
- logs:
1416
namespace: kmm-operator-system
1517
selector:
1618
- app.kubernetes.io/part-of=kmm
19+
- logs:
20+
namespace: olm
21+
- logs:
22+
namespace: operators
1723
hostCollectors:
1824
- cpu: {}
1925
- hostOS: {}

0 commit comments

Comments
 (0)