diff --git a/README.md b/README.md index e705dbab..9c9f7d8d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ACS Operator Index -This repository is for building and releasing the ACS operator indexes on Konflux. +This repository is for building and releasing the ACS operator indexes on Konflux.\ It's for updating Operator Catalogs, i.e., so OpenShift clusters can see new versions of ACS operator in their OperatorHub. @@ -17,7 +17,7 @@ Do the following changes in the `catalog-template.yaml` file. 1. Add bundle image. 1. Find entries with `schema: olm.bundle` towards the end of the file. - 2. Add a new entry for your bundle image. + 2. Add a new entry for your bundle image.\ It should look something like this: ```yaml - schema: olm.bundle @@ -28,7 +28,7 @@ Do the following changes in the `catalog-template.yaml` file. * Keep entries sorted according to version. * Add a comment stating the version, see how it's done for other items there. * You may add bundle images from `quay.io`, `brew.registry.redhat.io` and so on (provided they exist and are - pullable) during development and/or when preparing to release. + pullable) during development and/or when preparing to release.\ Ultimately, all released bundle images must come from `registry.redhat.io/advanced-cluster-security/rhacs-operator-bundle` repo because this is where customers expect to find them. There's a CI check which prevents pushing to `master` if there's any bundle from @@ -56,8 +56,8 @@ Do the following changes in the `catalog-template.yaml` file. after `4.8.1`, that'd be `8` and `1`; when you add `4.9.0` after `4.8.3`, that'd be `8` and `3`), * `(Y-1)` with the value of `Y` minus 1 (e.g., when you add `4.8.2`, that'd be `7`). 3. If the item you added is not the last one in the `entries` list, i.e., not the highest version, adjust the next - item in the `entries` list. - Set its `replaces:` to be `rhacs-operator.v4.Y.Z`. + item in the `entries` list.\ + Set its `replaces:` to be `rhacs-operator.v4.Y.Z`.\ For example: ```yaml - &bundle-4-7-4 # <-------- this was already there @@ -132,16 +132,16 @@ See [konflux docs](https://github.com/konflux-ci/build-definitions/blob/c93ea73d 1. Make sure you [logged in](https://spaces.redhat.com/pages/viewpage.action?pageId=407312060#HowtoeverythingKonfluxforRHACS-GettingocCLItoworkwithKonflux) to the Konflux cluster. 2. Make sure you checked out the latest master branch: `git checkout master && git pull` -3. Generate Release and Snapshot CRs by running `./scripts/generate-releases.sh `. Use `staging` for test release and `prod` for production one. -4. (Skip for `staging` release.) Create a PR which adds the file created by the script, get the PR reviewed and merged. -5. (Skip for `staging` release.) Go to the [#acs-operator-index-release](https://redhat.enterprise.slack.com/archives/C096WU0GZUG) channel, and: +3. Generate Release and Snapshot CRs by running `./scripts/generate-releases.sh `. Use `stage` for test release and `prod` for production one. +4. (Skip for `stage` release.) Create a PR which adds the file created by the script, get the PR reviewed and merged. +5. (Skip for `stage` release.) Go to the [#acs-operator-index-release](https://redhat.enterprise.slack.com/archives/C096WU0GZUG) channel, and: 1. make sure the previous operator index release is complete (has a green check mark emoticon) 2. if not, coordinate with the person conducting that release 3. once that release is complete, start a new thread for your release -6. Apply generated CRs to the cluster: `oc create -f release-history/--.yaml` +6. Apply generated CRs to the cluster: `oc create -f release-history/--.yaml` 7. Monitor release [using monitor release script](#monitoring-release). Each supported OCP version has its own `Release`. Successfully finished `Release` has `Succeeded` status. 8. Follow [the restarting release step below](#restarting-konflux-release) if any of the `Release`s fails for any OCP version. -9. (Skip for `staging` release.) Once done, go back to the Slack thread you started earlier, add a message that your release is done and add a green check mark emoticon on the initial message of the thread. +9. (Skip for `stage` release.) Once done, go back to the Slack thread you started earlier, add a message that your release is done and add a green check mark emoticon on the initial message of the thread. 10. Once releases for all OCP versions successfully finish, then the operator catalog release is done. If you perform it as part of a bigger release procedure, you should go back to that procedure and continue with further steps. diff --git a/scripts/generate-releases.sh b/scripts/generate-releases.sh index 235052ba..0d2242a6 100755 --- a/scripts/generate-releases.sh +++ b/scripts/generate-releases.sh @@ -39,7 +39,7 @@ usage() { if [[ "$#" -lt 1 || "$#" -gt 3 || "${1:-}" == "--help" ]]; then echo "USAGE: ./$(basename "${BASH_SOURCE[0]}") [COMMIT] [BRANCH]" >&2 echo "" >&2 - echo "ENVIRONMENT - allowed values: staging|prod" >&2 + echo "ENVIRONMENT - allowed values: stage|prod" >&2 echo "COMMIT - a SHA of the commit to pull Snapshots only with this commit label for the Release." >&2 echo "If provided commit SHA is less than 40 characters then it will be expanded to a full 40-characters long SHA. Default: currently checked out commit" >&2 echo "BRANCH - an optional parameter to specify git branch name for filtering snapshots by having branch name in annotations. Default: currently checked out branch" >&2 @@ -49,12 +49,12 @@ usage() { fi } -# Validate environment input and ensure it is either 'staging' or 'prod' (for master branch only). +# Validate environment input and ensure it is either 'stage' or 'prod' (for master branch only). validate_environment() { local -r environment="$1" local -r branch="$2" - if [[ "${environment}" != "staging" && "${environment}" != "prod" ]]; then - echo "ERROR: ENVIRONMENT input must either be 'staging' or 'prod'." >&2 + if [[ "${environment}" != "stage" && "${environment}" != "prod" ]]; then + echo "ERROR: ENVIRONMENT input must either be 'stage' or 'prod'." >&2 return 1 fi if [[ "${environment}" == "prod" && "${branch}" != "master" ]]; then @@ -100,29 +100,20 @@ generate_release_resources() { local -r commit="$2" local -r snapshots_data="$3" - local release_name + local release_name_suffix local snapshot local application local release_plan - case ${environment} in - staging) - env_short=stg - ;; - prod) - env_short=prd - ;; - esac - - release_name="$(date +"%Y-%m-%d")-$(git rev-parse --short "$commit")-${environment}" - release_name_short="$(date +"%Y%m%d")-$(git rev-parse --short "$commit")-${env_short}" # save space for retry suffix + release_name_suffix="$(date +"%Y%m%d")-${environment}-$(git rev-parse --short "$commit")" whitelist_file="$ROOT_DIR/release-history/.whitelist.yaml" - out_file="$ROOT_DIR/release-history/${release_name}.yaml" + out_file="$ROOT_DIR/release-history/${release_name_suffix}.yaml" + echo "Writing resources to ${out_file} ..." >&2 while IFS= read -r line do snapshot="$(echo "$line" | cut -d "|" -f 1)" - snapshot_copy="${snapshot%-*}-${release_name}" # replace random suffix with release name + snapshot_copy_name="$(echo "${snapshot%-*}-${release_name_suffix}" | cut -c -63)" # Replace random suffix with release name and crop to 63 characters to avoid running over the Kubernetes limit. echo "---" kubectl -n rh-acs-tenant get snapshot.appstudio.redhat.com "${snapshot}" -o yaml | \ "${YQ}" -P 'load("'"${whitelist_file}"'") as $whitelisted @@ -133,24 +124,28 @@ generate_release_resources() { "metadata": { "annotations": .metadata.annotations + {"acs.redhat.com/original-snapshot-name": "'"${snapshot}"'"}, "labels": .metadata.labels, - "name": "'"${snapshot_copy}"'", + "name": "'"${snapshot_copy_name}"'", "namespace": .metadata.namespace }, "spec": .spec }' application="$(echo "$line" | cut -d "|" -f 2)" + + # Crop the release name to 51 characters to avoid exceeding the Kubernetes limit of 63 characters for re-runs. + release_name_with_application="$(echo "${application}-${release_name_suffix}" | cut -c -51)" release_plan="${application/acs-operator-index/acs-operator-index-${environment}}" + sed -E 's/^[[:blank:]]{8}//' <<<" --- apiVersion: appstudio.redhat.com/v1alpha1 kind: Release metadata: - name: ${application}-${release_name_short} + name: ${release_name_with_application} namespace: rh-acs-tenant spec: releasePlan: ${release_plan} - snapshot: ${snapshot_copy}" + snapshot: ${snapshot_copy_name}" done <<< "$snapshots_data" > "${out_file}"