|
| 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: Run e2e tests |
| 115 | + run: | |
| 116 | + export CODEFLARE_TEST_OUTPUT_DIR=${{ env.TEMP_DIR }} |
| 117 | + echo "CODEFLARE_TEST_OUTPUT_DIR=${CODEFLARE_TEST_OUTPUT_DIR}" >> $GITHUB_ENV |
| 118 | +
|
| 119 | + set -euo pipefail |
| 120 | + go test -timeout 30m -v ./test/e2e -json 2>&1 | tee ${CODEFLARE_TEST_OUTPUT_DIR}/gotest-original.log | gotestfmt |
| 121 | +
|
| 122 | + - name: Build operator and catalog image |
| 123 | + run: | |
| 124 | + make image-push |
| 125 | + make bundle-build |
| 126 | + make bundle-push |
| 127 | + make catalog-build-from-index |
| 128 | + make catalog-push |
| 129 | + env: |
| 130 | + IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator:v0.0.1" |
| 131 | + BUNDLE_IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator-bundle:v0.0.1" |
| 132 | + CATALOG_IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator-catalog:v0.0.1" |
| 133 | + OPM_BUNDLE_OPT: "--use-http" |
| 134 | + BUNDLE_PUSH_OPT: "--tls-verify=false" |
| 135 | + CATALOG_PUSH_OPT: "--tls-verify=false" |
| 136 | + |
| 137 | + - name: Update Operator to the built version |
| 138 | + run: | |
| 139 | + ORIGINAL_POD_NAME=$(kubectl get pod -l app.kubernetes.io/name=codeflare-operator -n openshift-operators -o json | jq -r .items[].metadata.name) |
| 140 | + echo "Running old operator pod name is ${ORIGINAL_POD_NAME}" |
| 141 | +
|
| 142 | + echo Updating custom CatalogSource image to the built CatalogSource with latest operator |
| 143 | + kubectl patch CatalogSource codeflare-olm-test -n olm --type merge --patch "{\"spec\":{\"image\":\"${CATALOG_IMG}\"}}" |
| 144 | +
|
| 145 | + echo Waiting for previous operator pod to get deleted |
| 146 | + kubectl wait --timeout=120s --for=delete pod/${ORIGINAL_POD_NAME} -n openshift-operators |
| 147 | +
|
| 148 | + echo Waiting for Subscription to be ready |
| 149 | + make wait-for-subscription |
| 150 | +
|
| 151 | + echo Waiting for Deployment to be ready |
| 152 | + make wait-for-deployment -e TIMEOUT=60 -e DEPLOYMENT_NAME="codeflare-operator-manager" -e DEPLOYMENT_NAMESPACE="openshift-operators" |
| 153 | +
|
| 154 | + echo Checking that correct CSV is available |
| 155 | + CSV_VERSION=$(kubectl get ClusterServiceVersion/codeflare-operator.${VERSION} -n openshift-operators -o json | jq -r .spec.version) |
| 156 | + if [ "v${CSV_VERSION}" != "${VERSION}" ]; then |
| 157 | + echo "CSV version v${CSV_VERSION} doesn't match expected version ${VERSION}" |
| 158 | + exit 1 |
| 159 | + fi |
| 160 | + env: |
| 161 | + CATALOG_IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator-catalog:v0.0.1" |
| 162 | + SUBSCRIPTION_NAME: "codeflare-operator" |
| 163 | + SUBSCRIPTION_NAMESPACE: "openshift-operators" |
| 164 | + |
| 165 | + - name: Run e2e tests against built operator |
| 166 | + run: | |
| 167 | + set -euo pipefail |
| 168 | + go test -timeout 30m -v ./test/e2e -json 2>&1 | tee ${CODEFLARE_TEST_OUTPUT_DIR}/gotest-upgraded.log | gotestfmt |
| 169 | +
|
| 170 | + - name: Print CodeFlare operator logs |
| 171 | + if: always() && steps.deploy.outcome == 'success' |
| 172 | + run: | |
| 173 | + echo "Printing CodeFlare operator logs" |
| 174 | + kubectl logs -n openshift-operators --tail -1 -l app.kubernetes.io/name=codeflare-operator | tee ${CODEFLARE_TEST_OUTPUT_DIR}/codeflare-operator.log |
| 175 | +
|
| 176 | + - name: Print MCAD controller logs |
| 177 | + if: always() && steps.deploy.outcome == 'success' |
| 178 | + run: | |
| 179 | + echo "Printing MCAD controller logs" |
| 180 | + kubectl logs -n codeflare-system --tail -1 -l component=multi-cluster-application-dispatcher | tee ${CODEFLARE_TEST_OUTPUT_DIR}/mcad.log |
| 181 | +
|
| 182 | + - name: Print KubeRay operator logs |
| 183 | + if: always() && steps.deploy.outcome == 'success' |
| 184 | + run: | |
| 185 | + echo "Printing KubeRay operator logs" |
| 186 | + kubectl logs -n ray-system --tail -1 -l app.kubernetes.io/name=kuberay | tee ${CODEFLARE_TEST_OUTPUT_DIR}/kuberay.log |
| 187 | +
|
| 188 | + - name: Upload logs |
| 189 | + uses: actions/upload-artifact@v3 |
| 190 | + if: always() && steps.deploy.outcome == 'success' |
| 191 | + with: |
| 192 | + name: logs |
| 193 | + retention-days: 10 |
| 194 | + path: | |
| 195 | + ${{ env.CODEFLARE_TEST_OUTPUT_DIR }}/**/*.log |
0 commit comments