Skip to content

Commit 032c5b7

Browse files
ROX-30269: ensure that the full release name is maximum 51 chars long (#238)
## Changes * Enforce maximum length of 51 characters for release names to allow for 12 chars `-rerun-abcde` suffix from Konflux * Switch to consistent `stage` name for pre-prod releases. Generated release files after this PR will be named like `20251104-stage-b6926eb.yaml` (no more dashes in the date & `stage` suffix) ---------- Co-authored-by: Misha Sugakov <[email protected]>
1 parent dcb1586 commit 032c5b7

File tree

2 files changed

+26
-31
lines changed

2 files changed

+26
-31
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ACS Operator Index
22

3-
This repository is for building and releasing the ACS operator indexes on Konflux.
3+
This repository is for building and releasing the ACS operator indexes on Konflux.\
44
It's for updating Operator Catalogs, i.e., so OpenShift clusters can see new versions of ACS operator in their
55
OperatorHub.
66

@@ -17,7 +17,7 @@ Do the following changes in the `catalog-template.yaml` file.
1717

1818
1. Add bundle image.
1919
1. Find entries with `schema: olm.bundle` towards the end of the file.
20-
2. Add a new entry for your bundle image.
20+
2. Add a new entry for your bundle image.\
2121
It should look something like this:
2222
```yaml
2323
- schema: olm.bundle
@@ -28,7 +28,7 @@ Do the following changes in the `catalog-template.yaml` file.
2828
* Keep entries sorted according to version.
2929
* Add a comment stating the version, see how it's done for other items there.
3030
* You may add bundle images from `quay.io`, `brew.registry.redhat.io` and so on (provided they exist and are
31-
pullable) during development and/or when preparing to release.
31+
pullable) during development and/or when preparing to release.\
3232
Ultimately, all released bundle images must come from
3333
`registry.redhat.io/advanced-cluster-security/rhacs-operator-bundle` repo because this is where customers expect
3434
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.
5656
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`),
5757
* `(Y-1)` with the value of `Y` minus 1 (e.g., when you add `4.8.2`, that'd be `7`).
5858
3. If the item you added is not the last one in the `entries` list, i.e., not the highest version, adjust the next
59-
item in the `entries` list.
60-
Set its `replaces:` to be `rhacs-operator.v4.Y.Z`.
59+
item in the `entries` list.\
60+
Set its `replaces:` to be `rhacs-operator.v4.Y.Z`.\
6161
For example:
6262
```yaml
6363
- &bundle-4-7-4 # <-------- this was already there
@@ -132,16 +132,16 @@ See [konflux docs](https://github.com/konflux-ci/build-definitions/blob/c93ea73d
132132
133133
1. Make sure you [logged in](https://spaces.redhat.com/pages/viewpage.action?pageId=407312060#HowtoeverythingKonfluxforRHACS-GettingocCLItoworkwithKonflux) to the Konflux cluster.
134134
2. Make sure you checked out the latest master branch: `git checkout master && git pull`
135-
3. Generate Release and Snapshot CRs by running `./scripts/generate-releases.sh <staging|prod>`. Use `staging` for test release and `prod` for production one.
136-
4. (Skip for `staging` release.) Create a PR which adds the file created by the script, get the PR reviewed and merged.
137-
5. (Skip for `staging` release.) Go to the [#acs-operator-index-release](https://redhat.enterprise.slack.com/archives/C096WU0GZUG) channel, and:
135+
3. Generate Release and Snapshot CRs by running `./scripts/generate-releases.sh <stage|prod>`. Use `stage` for test release and `prod` for production one.
136+
4. (Skip for `stage` release.) Create a PR which adds the file created by the script, get the PR reviewed and merged.
137+
5. (Skip for `stage` release.) Go to the [#acs-operator-index-release](https://redhat.enterprise.slack.com/archives/C096WU0GZUG) channel, and:
138138
1. make sure the previous operator index release is complete (has a green check mark emoticon)
139139
2. if not, coordinate with the person conducting that release
140140
3. once that release is complete, start a new thread for your release
141-
6. Apply generated CRs to the cluster: `oc create -f release-history/<YYYY-MM-DD>-<SHA>-<staging|prod>.yaml`
141+
6. Apply generated CRs to the cluster: `oc create -f release-history/<YYYYMMDD>-<stage|prod>-<SHA>.yaml`
142142
7. Monitor release [using monitor release script](#monitoring-release). Each supported OCP version has its own `Release`. Successfully finished `Release` has `Succeeded` status.
143143
8. Follow [the restarting release step below](#restarting-konflux-release) if any of the `Release`s fails for any OCP version.
144-
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.
144+
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.
145145
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.
146146
147147

scripts/generate-releases.sh

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ usage() {
3939
if [[ "$#" -lt 1 || "$#" -gt 3 || "${1:-}" == "--help" ]]; then
4040
echo "USAGE: ./$(basename "${BASH_SOURCE[0]}") <ENVIRONMENT> [COMMIT] [BRANCH]" >&2
4141
echo "" >&2
42-
echo "ENVIRONMENT - allowed values: staging|prod" >&2
42+
echo "ENVIRONMENT - allowed values: stage|prod" >&2
4343
echo "COMMIT - a SHA of the commit to pull Snapshots only with this commit label for the Release." >&2
4444
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
4545
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() {
4949
fi
5050
}
5151

52-
# Validate environment input and ensure it is either 'staging' or 'prod' (for master branch only).
52+
# Validate environment input and ensure it is either 'stage' or 'prod' (for master branch only).
5353
validate_environment() {
5454
local -r environment="$1"
5555
local -r branch="$2"
56-
if [[ "${environment}" != "staging" && "${environment}" != "prod" ]]; then
57-
echo "ERROR: ENVIRONMENT input must either be 'staging' or 'prod'." >&2
56+
if [[ "${environment}" != "stage" && "${environment}" != "prod" ]]; then
57+
echo "ERROR: ENVIRONMENT input must either be 'stage' or 'prod'." >&2
5858
return 1
5959
fi
6060
if [[ "${environment}" == "prod" && "${branch}" != "master" ]]; then
@@ -100,29 +100,20 @@ generate_release_resources() {
100100
local -r commit="$2"
101101
local -r snapshots_data="$3"
102102

103-
local release_name
103+
local release_name_suffix
104104
local snapshot
105105
local application
106106
local release_plan
107107

108-
case ${environment} in
109-
staging)
110-
env_short=stg
111-
;;
112-
prod)
113-
env_short=prd
114-
;;
115-
esac
116-
117-
release_name="$(date +"%Y-%m-%d")-$(git rev-parse --short "$commit")-${environment}"
118-
release_name_short="$(date +"%Y%m%d")-$(git rev-parse --short "$commit")-${env_short}" # save space for retry suffix
108+
release_name_suffix="$(date +"%Y%m%d")-${environment}-$(git rev-parse --short "$commit")"
119109
whitelist_file="$ROOT_DIR/release-history/.whitelist.yaml"
120-
out_file="$ROOT_DIR/release-history/${release_name}.yaml"
110+
out_file="$ROOT_DIR/release-history/${release_name_suffix}.yaml"
111+
121112
echo "Writing resources to ${out_file} ..." >&2
122113
while IFS= read -r line
123114
do
124115
snapshot="$(echo "$line" | cut -d "|" -f 1)"
125-
snapshot_copy="${snapshot%-*}-${release_name}" # replace random suffix with release name
116+
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.
126117
echo "---"
127118
kubectl -n rh-acs-tenant get snapshot.appstudio.redhat.com "${snapshot}" -o yaml | \
128119
"${YQ}" -P 'load("'"${whitelist_file}"'") as $whitelisted
@@ -133,24 +124,28 @@ generate_release_resources() {
133124
"metadata": {
134125
"annotations": .metadata.annotations + {"acs.redhat.com/original-snapshot-name": "'"${snapshot}"'"},
135126
"labels": .metadata.labels,
136-
"name": "'"${snapshot_copy}"'",
127+
"name": "'"${snapshot_copy_name}"'",
137128
"namespace": .metadata.namespace
138129
},
139130
"spec": .spec
140131
}'
141132

142133
application="$(echo "$line" | cut -d "|" -f 2)"
134+
135+
# Crop the release name to 51 characters to avoid exceeding the Kubernetes limit of 63 characters for re-runs.
136+
release_name_with_application="$(echo "${application}-${release_name_suffix}" | cut -c -51)"
143137
release_plan="${application/acs-operator-index/acs-operator-index-${environment}}"
138+
144139
sed -E 's/^[[:blank:]]{8}//' <<<"
145140
---
146141
apiVersion: appstudio.redhat.com/v1alpha1
147142
kind: Release
148143
metadata:
149-
name: ${application}-${release_name_short}
144+
name: ${release_name_with_application}
150145
namespace: rh-acs-tenant
151146
spec:
152147
releasePlan: ${release_plan}
153-
snapshot: ${snapshot_copy}"
148+
snapshot: ${snapshot_copy_name}"
154149

155150
done <<< "$snapshots_data" > "${out_file}"
156151

0 commit comments

Comments
 (0)