Skip to content

Commit 9c269d0

Browse files
sutaakaropenshift-merge-robot
authored andcommitted
OLM install and upgrade PR check for CodeFlare stack
1 parent 70f0719 commit 9c269d0

File tree

8 files changed

+305
-45
lines changed

8 files changed

+305
-45
lines changed

.github/actions/kind/action.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "Set up KinD"
2+
description: "Step to start and configure KinD cluster"
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Init directories
8+
shell: bash
9+
run: |
10+
TEMP_DIR="$(pwd)/tmp"
11+
mkdir -p "${TEMP_DIR}"
12+
echo "TEMP_DIR=${TEMP_DIR}" >> $GITHUB_ENV
13+
14+
mkdir -p "$(pwd)/bin"
15+
echo "$(pwd)/bin" >> $GITHUB_PATH
16+
17+
- name: Container image registry
18+
shell: bash
19+
run: |
20+
podman run -d -p 5000:5000 --name registry registry:2.8.1
21+
22+
export REGISTRY_ADDRESS=$(hostname -i):5000
23+
echo "REGISTRY_ADDRESS=${REGISTRY_ADDRESS}" >> $GITHUB_ENV
24+
echo "Container image registry started at ${REGISTRY_ADDRESS}"
25+
26+
KIND_CONFIG_FILE=${{ env.TEMP_DIR }}/kind.yaml
27+
echo "KIND_CONFIG_FILE=${KIND_CONFIG_FILE}" >> $GITHUB_ENV
28+
envsubst < .github/resources-kind/kind.yaml > ${KIND_CONFIG_FILE}
29+
30+
sudo --preserve-env=REGISTRY_ADDRESS sh -c 'cat > /etc/containers/registries.conf.d/local.conf <<EOF
31+
[[registry]]
32+
prefix = "$REGISTRY_ADDRESS"
33+
insecure = true
34+
location = "$REGISTRY_ADDRESS"
35+
EOF'
36+
37+
- name: Setup KinD cluster
38+
uses: helm/[email protected]
39+
with:
40+
cluster_name: cluster
41+
version: v0.17.0
42+
config: ${{ env.KIND_CONFIG_FILE }}
43+
44+
- name: Print cluster info
45+
shell: bash
46+
run: |
47+
echo "KinD cluster:"
48+
kubectl cluster-info
49+
kubectl describe nodes
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: operators.coreos.com/v1alpha1
2+
kind: CatalogSource
3+
metadata:
4+
name: codeflare-olm-test
5+
namespace: olm
6+
spec:
7+
displayName: ''
8+
grpcPodConfig:
9+
securityContextConfig: restricted
10+
image: "${CATALOG_BASE_IMG}"
11+
publisher: ''
12+
sourceType: grpc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: operators.coreos.com/v1
2+
kind: OperatorGroup
3+
metadata:
4+
name: openshift-operators
5+
namespace: openshift-operators
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: operators.coreos.com/v1alpha1
2+
kind: Subscription
3+
metadata:
4+
name: codeflare-operator
5+
namespace: openshift-operators
6+
spec:
7+
channel: alpha
8+
installPlanApproval: Automatic
9+
name: codeflare-operator
10+
source: codeflare-olm-test
11+
sourceNamespace: olm

.github/workflows/e2e_tests.yaml

+4-42
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ jobs:
5454
with:
5555
submodules: recursive
5656

57-
- name: Init directories
58-
run: |
59-
TEMP_DIR="$(pwd)/tmp"
60-
mkdir -p "${TEMP_DIR}"
61-
echo "TEMP_DIR=${TEMP_DIR}" >> $GITHUB_ENV
62-
63-
mkdir -p "$(pwd)/bin"
64-
echo "$(pwd)/bin" >> $GITHUB_PATH
65-
6657
- name: Set Go
6758
uses: actions/setup-go@v3
6859
with:
@@ -73,37 +64,8 @@ jobs:
7364
with:
7465
token: ${{ secrets.GITHUB_TOKEN }}
7566

76-
- name: Container image registry
77-
run: |
78-
podman run -d -p 5000:5000 --name registry registry:2.8.1
79-
80-
export REGISTRY_ADDRESS=$(hostname -i):5000
81-
echo "REGISTRY_ADDRESS=${REGISTRY_ADDRESS}" >> $GITHUB_ENV
82-
echo "Container image registry started at ${REGISTRY_ADDRESS}"
83-
84-
KIND_CONFIG_FILE=${{ env.TEMP_DIR }}/kind.yaml
85-
echo "KIND_CONFIG_FILE=${KIND_CONFIG_FILE}" >> $GITHUB_ENV
86-
envsubst < ./test/e2e/kind.yaml > ${KIND_CONFIG_FILE}
87-
88-
sudo --preserve-env=REGISTRY_ADDRESS sh -c 'cat > /etc/containers/registries.conf.d/local.conf <<EOF
89-
[[registry]]
90-
prefix = "$REGISTRY_ADDRESS"
91-
insecure = true
92-
location = "$REGISTRY_ADDRESS"
93-
EOF'
94-
95-
- name: Setup KinD cluster
96-
uses: helm/[email protected]
97-
with:
98-
cluster_name: cluster
99-
version: v0.17.0
100-
config: ${{ env.KIND_CONFIG_FILE }}
101-
102-
- name: Print cluster info
103-
run: |
104-
echo "KinD cluster:"
105-
kubectl cluster-info
106-
kubectl describe nodes
67+
- name: Setup and start KinD cluster
68+
uses: ./.github/actions/kind
10769

10870
- name: Deploy CodeFlare stack
10971
id: deploy
@@ -120,8 +82,8 @@ jobs:
12082
- name: Run e2e tests
12183
run: |
12284
export CODEFLARE_TEST_TIMEOUT_SHORT=1m
123-
export CODEFLARE_TEST_TIMEOUT_MEDIUM=3m
124-
export CODEFLARE_TEST_TIMEOUT_LONG=8m
85+
export CODEFLARE_TEST_TIMEOUT_MEDIUM=5m
86+
export CODEFLARE_TEST_TIMEOUT_LONG=10m
12587
12688
export CODEFLARE_TEST_OUTPUT_DIR=${{ env.TEMP_DIR }}
12789
echo "CODEFLARE_TEST_OUTPUT_DIR=${CODEFLARE_TEST_OUTPUT_DIR}" >> $GITHUB_ENV

.github/workflows/olm_tests.yaml

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# This workflow will build the CodeFlare Operator image and catalog containing bundle with this image, execute OLM upgrade tests using this catalog
2+
3+
name: OLM Install and Upgrade
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- main
9+
- 'release-*'
10+
paths-ignore:
11+
- 'docs/**'
12+
- '**.adoc'
13+
- '**.md'
14+
- 'LICENSE'
15+
16+
concurrency:
17+
group: ${{ github.head_ref }}-${{ github.workflow }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
kubernetes:
22+
runs-on: ubuntu-20.04
23+
timeout-minutes: 60
24+
env:
25+
OLM_VERSION: v0.24.0
26+
VERSION: "v0.0.0-ghaction" # Need to supply some semver version for bundle to be properly generated
27+
CATALOG_BASE_IMG: "registry.access.redhat.com/redhat/community-operator-index:v4.13"
28+
CODEFLARE_TEST_TIMEOUT_SHORT: "1m"
29+
CODEFLARE_TEST_TIMEOUT_MEDIUM: "5m"
30+
CODEFLARE_TEST_TIMEOUT_LONG: "10m"
31+
32+
steps:
33+
- name: Cleanup
34+
run: |
35+
ls -lart
36+
echo "Initial status:"
37+
df -h
38+
39+
echo "Cleaning up resources:"
40+
sudo swapoff -a
41+
sudo rm -f /swapfile
42+
sudo apt clean
43+
sudo rm -rf /usr/share/dotnet
44+
sudo rm -rf /opt/ghc
45+
sudo rm -rf "/usr/local/share/boost"
46+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
47+
docker rmi $(docker image ls -aq)
48+
49+
echo "Final status:"
50+
df -h
51+
52+
- uses: actions/checkout@v3
53+
with:
54+
fetch-depth: 0 # fetching also previous commits to get tags
55+
56+
- name: Set Go
57+
uses: actions/setup-go@v3
58+
with:
59+
go-version: v1.18
60+
61+
- name: Set up gotestfmt
62+
uses: gotesttools/gotestfmt-action@v2
63+
with:
64+
token: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- name: Setup and start KinD cluster
67+
uses: ./.github/actions/kind
68+
69+
- name: Install OLM
70+
run: |
71+
kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${OLM_VERSION}/crds.yaml
72+
# wait for a while to be sure CRDs are installed
73+
sleep 1
74+
kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${OLM_VERSION}/olm.yaml
75+
76+
- name: Create openshift-operator namespace and OperatorGroup
77+
run: |
78+
# Need to use openshift-operator namespace due to https://github.com/project-codeflare/codeflare-operator/issues/161
79+
kubectl create namespace openshift-operators
80+
kubectl create -f .github/resources-olm-upgrade/operatorgroup.yaml
81+
82+
- name: Deploy latest released CodeFlare operator from OLM
83+
id: deploy
84+
run: |
85+
echo Deploying CodeFlare operator using Subscription
86+
envsubst < .github/resources-olm-upgrade/catalogsource.yaml > ${{ env.TEMP_DIR }}/catalogsource.yaml
87+
envsubst < .github/resources-olm-upgrade/subscription.yaml > ${{ env.TEMP_DIR }}/subscription.yaml
88+
89+
kubectl create -f ${{ env.TEMP_DIR }}/catalogsource.yaml
90+
make wait-for-catalog-source
91+
92+
kubectl create -f ${{ env.TEMP_DIR }}/subscription.yaml
93+
94+
echo Waiting for Subscription to be ready
95+
make wait-for-subscription
96+
97+
echo Waiting for Deployment to be ready
98+
make wait-for-deployment -e TIMEOUT=60 -e DEPLOYMENT_NAME="codeflare-operator-manager" -e DEPLOYMENT_NAMESPACE="openshift-operators"
99+
env:
100+
CATALOG_SOURCE_NAME: "codeflare-olm-test"
101+
CATALOG_SOURCE_NAMESPACE: "olm"
102+
SUBSCRIPTION_NAME: "codeflare-operator"
103+
SUBSCRIPTION_NAMESPACE: "openshift-operators"
104+
105+
- name: Store latest CSV version as PREVIOUS_VERSION env variable (used for bundle build)
106+
run: |
107+
CSV_VERSION=$(kubectl get ClusterServiceVersion -l operators.coreos.com/codeflare-operator.openshift-operators='' -n openshift-operators -o json | jq -r .items[].spec.version)
108+
echo "PREVIOUS_VERSION=v$CSV_VERSION" >> $GITHUB_ENV
109+
110+
- name: Deploy CodeFlare stack (MCAD, KubeRay)
111+
run: |
112+
make setup-e2e
113+
114+
- name: Build operator and catalog image
115+
run: |
116+
make image-push
117+
make bundle-build
118+
make bundle-push
119+
make catalog-build-from-index
120+
make catalog-push
121+
env:
122+
IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator:v0.0.1"
123+
BUNDLE_IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator-bundle:v0.0.1"
124+
CATALOG_IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator-catalog:v0.0.1"
125+
OPM_BUNDLE_OPT: "--use-http"
126+
BUNDLE_PUSH_OPT: "--tls-verify=false"
127+
CATALOG_PUSH_OPT: "--tls-verify=false"
128+
129+
- name: Update Operator to the built version
130+
run: |
131+
ORIGINAL_POD_NAME=$(kubectl get pod -l app.kubernetes.io/name=codeflare-operator -n openshift-operators -o json | jq -r .items[].metadata.name)
132+
echo "Running old operator pod name is ${ORIGINAL_POD_NAME}"
133+
134+
echo Updating custom CatalogSource image to the built CatalogSource with latest operator
135+
kubectl patch CatalogSource codeflare-olm-test -n olm --type merge --patch "{\"spec\":{\"image\":\"${CATALOG_IMG}\"}}"
136+
137+
echo Waiting for previous operator pod to get deleted
138+
kubectl wait --timeout=120s --for=delete pod/${ORIGINAL_POD_NAME} -n openshift-operators
139+
140+
echo Waiting for Subscription to be ready
141+
make wait-for-subscription
142+
143+
echo Waiting for Deployment to be ready
144+
make wait-for-deployment -e TIMEOUT=60 -e DEPLOYMENT_NAME="codeflare-operator-manager" -e DEPLOYMENT_NAMESPACE="openshift-operators"
145+
146+
echo Checking that correct CSV is available
147+
CSV_VERSION=$(kubectl get ClusterServiceVersion/codeflare-operator.${VERSION} -n openshift-operators -o json | jq -r .spec.version)
148+
if [ "v${CSV_VERSION}" != "${VERSION}" ]; then
149+
echo "CSV version v${CSV_VERSION} doesn't match expected version ${VERSION}"
150+
exit 1
151+
fi
152+
env:
153+
CATALOG_IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator-catalog:v0.0.1"
154+
SUBSCRIPTION_NAME: "codeflare-operator"
155+
SUBSCRIPTION_NAMESPACE: "openshift-operators"
156+
157+
- name: Run e2e tests against built operator
158+
run: |
159+
export CODEFLARE_TEST_OUTPUT_DIR=${{ env.TEMP_DIR }}
160+
echo "CODEFLARE_TEST_OUTPUT_DIR=${CODEFLARE_TEST_OUTPUT_DIR}" >> $GITHUB_ENV
161+
162+
set -euo pipefail
163+
go test -timeout 30m -v ./test/e2e -json 2>&1 | tee ${CODEFLARE_TEST_OUTPUT_DIR}/gotest.log | gotestfmt
164+
165+
- name: Print CodeFlare operator logs
166+
if: always() && steps.deploy.outcome == 'success'
167+
run: |
168+
echo "Printing CodeFlare operator logs"
169+
kubectl logs -n openshift-operators --tail -1 -l app.kubernetes.io/name=codeflare-operator | tee ${CODEFLARE_TEST_OUTPUT_DIR}/codeflare-operator.log
170+
171+
- name: Print MCAD controller logs
172+
if: always() && steps.deploy.outcome == 'success'
173+
run: |
174+
echo "Printing MCAD controller logs"
175+
kubectl logs -n codeflare-system --tail -1 -l component=multi-cluster-application-dispatcher | tee ${CODEFLARE_TEST_OUTPUT_DIR}/mcad.log
176+
177+
- name: Print KubeRay operator logs
178+
if: always() && steps.deploy.outcome == 'success'
179+
run: |
180+
echo "Printing KubeRay operator logs"
181+
kubectl logs -n ray-system --tail -1 -l app.kubernetes.io/name=kuberay | tee ${CODEFLARE_TEST_OUTPUT_DIR}/kuberay.log
182+
183+
- name: Upload logs
184+
uses: actions/upload-artifact@v3
185+
if: always() && steps.deploy.outcome == 'success'
186+
with:
187+
name: logs
188+
retention-days: 10
189+
path: |
190+
${{ env.CODEFLARE_TEST_OUTPUT_DIR }}/**/*.log

0 commit comments

Comments
 (0)