|
| 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-olm-upgrade: |
| 22 | + runs-on: ubuntu-latest-4core |
| 23 | + timeout-minutes: 60 |
| 24 | + env: |
| 25 | + OLM_VERSION: v0.25.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 | + - uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + fetch-depth: 0 # fetching also previous commits to get tags |
| 36 | + |
| 37 | + - name: Checkout common repo code |
| 38 | + uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + repository: 'project-codeflare/codeflare-common' |
| 41 | + ref: 'main' |
| 42 | + path: 'common' |
| 43 | + |
| 44 | + - name: Set Go |
| 45 | + uses: actions/setup-go@v5 |
| 46 | + with: |
| 47 | + go-version-file: './go.mod' |
| 48 | + |
| 49 | + - name: Set up gotestfmt |
| 50 | + uses: gotesttools/gotestfmt-action@v2 |
| 51 | + with: |
| 52 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Setup and start KinD cluster |
| 55 | + uses: ./common/github-actions/kind |
| 56 | + |
| 57 | + - name: Install OLM |
| 58 | + run: | |
| 59 | + kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${OLM_VERSION}/crds.yaml |
| 60 | + # wait for a while to be sure CRDs are installed |
| 61 | + sleep 1 |
| 62 | + kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${OLM_VERSION}/olm.yaml |
| 63 | + echo Wait for default CatalogSource to start |
| 64 | + kubectl wait -n ${{ env.CATALOG_SOURCE_NAMESPACE }} catalogsource/${{ env.CATALOG_SOURCE_NAME }} --for=jsonpath='{.status.connectionState.lastObservedState}'=READY --timeout=180s |
| 65 | + env: |
| 66 | + CATALOG_SOURCE_NAME: "operatorhubio-catalog" |
| 67 | + CATALOG_SOURCE_NAMESPACE: "olm" |
| 68 | + |
| 69 | + - name: Create openshift-operator namespace and OperatorGroup |
| 70 | + run: | |
| 71 | + # Need to use openshift-operator namespace due to https://github.com/project-codeflare/codeflare-operator/issues/161 |
| 72 | + kubectl create namespace openshift-operators |
| 73 | + kubectl create -f .github/resources-olm-upgrade/operatorgroup.yaml |
| 74 | +
|
| 75 | + - name: Deploy latest released CodeFlare operator from OLM |
| 76 | + id: deploy |
| 77 | + run: | |
| 78 | + echo Create the CodeFlare operator ConfigMap |
| 79 | + kubectl apply -n '${{ env.SUBSCRIPTION_NAMESPACE }}' -f config/e2e/config.yaml |
| 80 | +
|
| 81 | + echo Deploying CodeFlare operator using Subscription |
| 82 | + envsubst < .github/resources-olm-upgrade/catalogsource.yaml > ${{ env.TEMP_DIR }}/catalogsource.yaml |
| 83 | + envsubst < .github/resources-olm-upgrade/subscription.yaml > ${{ env.TEMP_DIR }}/subscription.yaml |
| 84 | +
|
| 85 | + kubectl create -f ${{ env.TEMP_DIR }}/catalogsource.yaml |
| 86 | +
|
| 87 | + echo Wait for CatalogSource ${{ env.CATALOG_SOURCE_NAME }} to start |
| 88 | + kubectl wait -n ${{ env.CATALOG_SOURCE_NAMESPACE }} catalogsource/${{ env.CATALOG_SOURCE_NAME }} --for=jsonpath='{.status.connectionState.lastObservedState}'=READY --timeout=180s |
| 89 | +
|
| 90 | + kubectl create -f ${{ env.TEMP_DIR }}/subscription.yaml |
| 91 | +
|
| 92 | + echo Waiting for Subscription to be ready |
| 93 | + kubectl wait -n ${{ env.SUBSCRIPTION_NAMESPACE }} subscription/${{ env.SUBSCRIPTION_NAME }} --for=jsonpath='{.status.state}'=AtLatestKnown --timeout=180s |
| 94 | +
|
| 95 | + echo Waiting for Deployment to be ready |
| 96 | + timeout 60 bash -c 'until [[ $(kubectl get deployment/codeflare-operator-manager -n '${{ env.SUBSCRIPTION_NAMESPACE }}') ]]; do sleep 5 && echo "$(kubectl get deployment/codeflare-operator-manager -n '${{ env.SUBSCRIPTION_NAMESPACE }}')"; done' |
| 97 | + kubectl wait -n ${{ env.SUBSCRIPTION_NAMESPACE }} deployment/codeflare-operator-manager --for=condition=Available=true --timeout=60s |
| 98 | + env: |
| 99 | + CATALOG_SOURCE_NAME: "codeflare-olm-test" |
| 100 | + CATALOG_SOURCE_NAMESPACE: "olm" |
| 101 | + SUBSCRIPTION_NAME: "codeflare-operator" |
| 102 | + SUBSCRIPTION_NAMESPACE: "openshift-operators" |
| 103 | + |
| 104 | + - name: Store latest CSV version as PREVIOUS_VERSION env variable (used for bundle build) |
| 105 | + run: | |
| 106 | + CSV_VERSION=$(kubectl get ClusterServiceVersion -l operators.coreos.com/codeflare-operator.openshift-operators='' -n openshift-operators -o json | jq -r .items[].spec.version) |
| 107 | + echo "PREVIOUS_VERSION=v$CSV_VERSION" >> $GITHUB_ENV |
| 108 | +
|
| 109 | + - name: Build operator and catalog image |
| 110 | + run: | |
| 111 | + make image-push |
| 112 | + make bundle-build |
| 113 | + make bundle-push |
| 114 | + make catalog-build-from-index |
| 115 | + make catalog-push |
| 116 | + env: |
| 117 | + IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator:v0.0.1" |
| 118 | + BUNDLE_IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator-bundle:v0.0.1" |
| 119 | + CATALOG_IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator-catalog:v0.0.1" |
| 120 | + OPM_BUNDLE_OPT: "--use-http" |
| 121 | + BUNDLE_PUSH_OPT: "--tls-verify=false" |
| 122 | + CATALOG_PUSH_OPT: "--tls-verify=false" |
| 123 | + |
| 124 | + - name: Update Operator to the built version |
| 125 | + run: | |
| 126 | + ORIGINAL_POD_NAME=$(kubectl get pod -l app.kubernetes.io/name=codeflare-operator -n openshift-operators -o json | jq -r .items[].metadata.name) |
| 127 | + echo "Running old operator pod name is ${ORIGINAL_POD_NAME}" |
| 128 | +
|
| 129 | + echo Updating custom CatalogSource image to the built CatalogSource with latest operator |
| 130 | + kubectl patch CatalogSource codeflare-olm-test -n olm --type merge --patch "{\"spec\":{\"image\":\"${CATALOG_IMG}\"}}" |
| 131 | +
|
| 132 | + echo Waiting for previous operator pod to get deleted |
| 133 | + kubectl wait --timeout=120s --for=delete pod/${ORIGINAL_POD_NAME} -n openshift-operators |
| 134 | +
|
| 135 | + echo Waiting for Subscription to be ready |
| 136 | + kubectl wait -n ${{ env.SUBSCRIPTION_NAMESPACE }} subscription/${{ env.SUBSCRIPTION_NAME }} --for=jsonpath='{.status.state}'=AtLatestKnown --timeout=180s |
| 137 | +
|
| 138 | + echo Waiting for Deployment to be ready |
| 139 | + timeout 60 bash -c 'until [[ $(kubectl get deployment/codeflare-operator-manager -n '${{ env.SUBSCRIPTION_NAMESPACE }}') ]]; do sleep 5 && echo "$(kubectl get deployment/codeflare-operator-manager -n '${{ env.SUBSCRIPTION_NAMESPACE }}')"; done' |
| 140 | + kubectl wait -n ${{ env.SUBSCRIPTION_NAMESPACE }} deployment/codeflare-operator-manager --for=condition=Available=true --timeout=60s |
| 141 | +
|
| 142 | + echo Checking that correct CSV is available |
| 143 | + CSV_VERSION=$(kubectl get ClusterServiceVersion/codeflare-operator.${VERSION} -n openshift-operators -o json | jq -r .spec.version) |
| 144 | + if [ "v${CSV_VERSION}" != "${VERSION}" ]; then |
| 145 | + echo "CSV version v${CSV_VERSION} doesn't match expected version ${VERSION}" |
| 146 | + exit 1 |
| 147 | + fi |
| 148 | + env: |
| 149 | + CATALOG_IMG: "${{ env.REGISTRY_ADDRESS }}/codeflare-operator-catalog:v0.0.1" |
| 150 | + SUBSCRIPTION_NAME: "codeflare-operator" |
| 151 | + SUBSCRIPTION_NAMESPACE: "openshift-operators" |
| 152 | + |
| 153 | + - name: Print CodeFlare operator logs |
| 154 | + if: always() && steps.deploy.outcome == 'success' |
| 155 | + run: | |
| 156 | + echo "Printing CodeFlare operator logs" |
| 157 | + mkdir logs |
| 158 | + kubectl logs -n openshift-operators --tail -1 -l app.kubernetes.io/name=codeflare-operator | tee logs/codeflare-operator.log |
| 159 | +
|
| 160 | + - name: Export all KinD pod logs |
| 161 | + uses: ./common/github-actions/kind-export-logs |
| 162 | + if: always() && steps.deploy.outcome == 'success' |
| 163 | + with: |
| 164 | + output-directory: logs |
| 165 | + |
| 166 | + - name: Upload logs |
| 167 | + uses: actions/upload-artifact@v4 |
| 168 | + if: always() && steps.deploy.outcome == 'success' |
| 169 | + with: |
| 170 | + name: logs |
| 171 | + retention-days: 10 |
| 172 | + path: logs/**/*.log |
0 commit comments