Skip to content

Commit 55eff77

Browse files
authored
[main] micro version bundle generation fixes (#3781)
* fixes bundle generation for .micro >=.2 versions * fixes * hack/generate/index-bundles.sh * make generated-files * make generated-files * missed the actual script * use kafkasource v1beta1 in kitchensink (for upgrade tests) * kitchensik test, use kafkasource v1beta1 also for readiness checks * skip EventTransform with SM enabled, SRVKE-1751
1 parent 7b09e51 commit 55eff77

File tree

18 files changed

+599
-210
lines changed

18 files changed

+599
-210
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ generate-ci-config:
286286

287287
generate-catalog:
288288
./hack/generate/catalog.sh
289+
./hack/generate/index-bundles.sh \
290+
olm-catalog/serverless-operator-index/index-bundles.yaml
289291
.PHONY: generate-catalog
290292

291293
generate-override-snapshot: install-tools

hack/generate/annotations.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ target="${2:?Provide a target annotations file as arg[2]}"
99
source "$(dirname "${BASH_SOURCE[0]}")/../lib/metadata.bash"
1010

1111
declare -A values
12-
values[operators.operatorframework.io.bundle.channel.default.v1]="$(metadata.get olm.channels.default)"
12+
values[operators.operatorframework.io.bundle.channel.default.v1]="$(metadata.get olm.channels.operator_default)"
1313
values[operators.operatorframework.io.bundle.channels.v1]="$(metadata.get olm.channels.default),$(metadata.get 'olm.channels.list[*]' | head -n 2 | tail -n 1)"
1414
values[operators.operatorframework.io.bundle.package.v1]="$(metadata.get project.name)"
1515

hack/generate/catalog.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function generate_catalog {
5858

5959
function add_channel {
6060
local channel catalog_template catalog current_version current_csv major \
61-
minor micro previous_version channel_entry version
61+
minor micro previous_version replaces_version channel_entry version
6262
catalog_template=${1?Pass catalog template path as arg[1]}
6363
channel=${2:?Pass channel name as arg[2]}
6464

@@ -73,8 +73,10 @@ function add_channel {
7373
# Handle the first entry specifically as it might be a z-stream release.
7474
if [[ "$micro" == "0" ]]; then
7575
previous_version="${major}.$(( minor-1 )).${micro}"
76+
replaces_version="${major}.$(( minor-1 )).${micro}"
7677
else
7778
previous_version="${major}.${minor}.0"
79+
replaces_version="${major}.${minor}.$(( micro-1 ))"
7880
fi
7981

8082
catalog=$(mktemp catalog-XXX.json)
@@ -97,7 +99,7 @@ function add_channel {
9799
should_add=0
98100
# Add entry to the channel if doesn't exist yet
99101
if [[ "${current_csv_entry}" == "" ]]; then
100-
replaces="serverless-operator.v${previous_version}"
102+
replaces="serverless-operator.v${replaces_version}"
101103
entry_with_same_replaces=$(yq read "${catalog_template}" "entries[name==${channel}].entries[replaces==${replaces}].name")
102104
if [[ "${entry_with_same_replaces}" == "" ]]; then
103105
should_add=1

hack/generate/dockerfile.sh

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ declare -A values
1414
values[NAME]="$(metadata.get project.name)"
1515
values[LATEST_VERSIONED_CHANNEL]="$(metadata.get 'olm.channels.list[1]')"
1616
values[DEFAULT_CHANNEL]="$(metadata.get olm.channels.default)"
17+
values[OPERATOR_DEFAULT_CHANNEL]="$(metadata.get olm.channels.operator_default)"
1718
values[VERSION]="$(metadata.get project.version)"
1819
values[SERVING_VERSION]="$(metadata.get dependencies.serving)"
1920
values[EVENTING_VERSION]="$(metadata.get dependencies.eventing)"
@@ -33,28 +34,6 @@ if [[ "$template" =~ index.Dockerfile ]]; then
3334
echo "Value: ${before} -> ${values[$before]}"
3435
sed --in-place "s|__${before}__|${values[${before}]}|" "$target"
3536
done
36-
37-
current_version=$(metadata.get 'project.version')
38-
major=$(versions.major "$current_version")
39-
minor=$(versions.minor "$current_version")
40-
micro=$(versions.micro "$current_version")
41-
42-
# One is already added in template
43-
num_csvs=$(( INDEX_IMAGE_NUM_CSVS-1 ))
44-
45-
# Generate additional entries
46-
for i in $(seq $num_csvs); do
47-
current_minor=$(( minor-i ))
48-
# If the current version is a z-stream then the following entries will
49-
# start with the same "minor" version.
50-
if [[ "$micro" != "0" ]]; then
51-
current_minor=$(( current_minor+1 ))
52-
fi
53-
current_version="${major}.${current_minor}.0"
54-
55-
sed --in-place "/opm render/a quay.io/redhat-user-workloads/ocp-serverless-tenant/serverless-operator-${major}${current_minor}/serverless-bundle:${current_version} \\\\" "$target"
56-
done
57-
5837
elif [[ "$template" =~ catalog.Dockerfile ]]; then
5938
while IFS=$'\n' read -r ocp_version; do
6039
values[OCP_VERSION]="${ocp_version}"

hack/generate/index-bundles.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuo pipefail
4+
5+
target="${1:?Provide a target index yaml file as arg[1]}"
6+
7+
# shellcheck disable=SC1091,SC1090
8+
source "$(dirname "${BASH_SOURCE[0]}")/../lib/__sources__.bash"
9+
10+
function add_previous_bundles {
11+
if [[ -n "${REGISTRY_REDHAT_IO_USERNAME:-}" ]] || [[ -n "${REGISTRY_REDHAT_IO_PASSWORD:-}" ]]; then
12+
skopeo login registry.redhat.io -u "${REGISTRY_REDHAT_IO_USERNAME}" -p "${REGISTRY_REDHAT_IO_PASSWORD}"
13+
fi
14+
15+
# We're adding just the "previous bundles"
16+
num_csvs=$(( INDEX_IMAGE_NUM_CSVS-1 ))
17+
18+
current_version=$(metadata.get 'project.version')
19+
major=$(versions.major "$current_version")
20+
minor=$(versions.minor "$current_version")
21+
micro=$(versions.micro "$current_version")
22+
23+
for i in $(seq $num_csvs); do
24+
current_minor=$(( minor ))
25+
current_micro=$(( micro-i ))
26+
if [[ "$current_micro" -le 0 ]]; then
27+
current_minor=$((minor + current_micro))
28+
current_micro=0
29+
fi
30+
31+
current_version="${major}.${current_minor}.${current_micro}"
32+
33+
opm render --skip-tls-verify -o yaml "registry.redhat.io/openshift-serverless-1/serverless-operator-bundle:${current_version}" >> "$target"
34+
done
35+
}
36+
# Clear the file.
37+
rm -f "${target}"
38+
39+
add_previous_bundles "${target}"

hack/generate/index.sh

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ target="${1:?Provide a target index yaml file as arg[1]}"
88
source "$(dirname "${BASH_SOURCE[0]}")/../lib/__sources__.bash"
99

1010
function add_channel_entries {
11-
local channel_entry_yaml channel target num_csvs
11+
local channel_entry_yaml channel target current_version replaces_version base_version
1212
channel=${1:?Provide channel name}
1313
target=${2:?Provide target file name}
1414
channel_entry_yaml="$(mktemp -t default-entry-XXXXX.yaml)"
@@ -26,51 +26,35 @@ EOF
2626
minor=$(versions.minor "$current_version")
2727
micro=$(versions.micro "$current_version")
2828

29-
# Handle the first entry specifically as it might be a z-stream release.
30-
if [[ "$micro" == "0" ]]; then
31-
previous_version="${major}.$(( minor-1 )).${micro}"
32-
else
33-
previous_version="${major}.${minor}.0"
34-
fi
29+
for i in $(seq "$INDEX_IMAGE_NUM_CSVS"); do
30+
current_major=$((major))
31+
current_minor=$((minor))
32+
current_micro=$((micro - i + 1))
3533

36-
cat << EOF | yq write --inplace --script - "$channel_entry_yaml"
37-
- command: update
38-
path: entries[+]
39-
value:
40-
name: "serverless-operator.v${current_version}"
41-
replaces: "serverless-operator.v${previous_version}"
42-
skipRange: ">=${previous_version} <${current_version}"
43-
EOF
44-
45-
# One is already added above specifically
46-
num_csvs=$(( INDEX_IMAGE_NUM_CSVS-1 ))
47-
48-
# Generate additional entries
49-
for i in $(seq $num_csvs); do
50-
current_minor=$(( minor-i ))
51-
previous_minor=$(( minor-i ))
52-
previous_minor=$(( previous_minor-1 ))
53-
# If the current version is a z-stream then the following entries will
54-
# start with the same "minor" version.
55-
if [[ "$micro" != "0" ]]; then
56-
current_minor=$(( current_minor+1 ))
57-
previous_minor=$(( previous_minor+1 ))
34+
if [[ "$current_micro" -le 0 ]]; then
35+
current_minor=$((minor + current_micro))
36+
current_micro=0
5837
fi
5938

60-
current_version="${major}.${current_minor}.0"
61-
previous_version="${major}.${previous_minor}.0"
39+
current_version="${current_major}.${current_minor}.${current_micro}"
40+
if [[ "$current_micro" == "0" ]]; then
41+
base_version="${current_major}.$(( current_minor-1 )).0"
42+
replaces_version="${current_major}.$(( current_minor-1 )).0"
43+
else
44+
base_version="${current_major}.${current_minor}.0"
45+
replaces_version="${current_major}.${current_minor}.$(( current_micro-1 ))"
46+
fi
6247

63-
# If this is the last item enter only name, without "replaces".
64-
if [[ $i -eq $num_csvs ]]; then
48+
if [[ $i -eq "$INDEX_IMAGE_NUM_CSVS" ]]; then
6549
yq write --inplace "$channel_entry_yaml" 'entries[+].name' "serverless-operator.v${current_version}"
6650
else
6751
cat << EOF | yq write --inplace --script - "$channel_entry_yaml"
6852
- command: update
6953
path: entries[+]
7054
value:
7155
name: "serverless-operator.v${current_version}"
72-
replaces: "serverless-operator.v${previous_version}"
73-
skipRange: ">=${previous_version} <${current_version}"
56+
replaces: "serverless-operator.v${replaces_version}"
57+
skipRange: ">=${base_version} <${current_version}"
7458
EOF
7559
fi
7660
done

hack/lib/images.bash

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,29 @@ function get_bundle_for_version() {
8888
app_version=${app_version%.*} # 134.0 -> 134
8989

9090
image=$(image_with_sha "${registry_prefix_quay}${app_version}/serverless-bundle:latest")
91+
image_version=$(bundle_image_version "${registry_prefix_quay}${app_version}/serverless-bundle:latest")
92+
9193
# As a backup, try also CI registry.
94+
# For .micro releases, it's possible we only have the _previous_ version in Konflux, so also check the version of the bundle
9295
local ci_bundle="registry.ci.openshift.org/knative/serverless-bundle"
93-
if [[ "${image}" == "" ]]; then
96+
if [[ "${image}" == "" || "${image_version}" != "${version}" ]]; then
9497
image=$(image_with_sha "${ci_bundle}:release-${version}" || echo "")
98+
image_version=$(bundle_image_version "${ci_bundle}:release-${version}")
9599
fi
96-
if [[ "${image}" == "" ]]; then
100+
if [[ "${image}" == "" || "${image_version}" != "${version}" ]]; then
97101
image=$(image_with_sha "${ci_bundle}:knative-main")
102+
image_version=$(bundle_image_version "${ci_bundle}:knative-main")
98103
fi
99104

100105
if [[ "${image}" == "" ]]; then
106+
echo "[ERROR] No image found for $version" > /dev/stderr
101107
exit 1
102108
fi
103109

110+
if [[ "${image_version}" != "${version}" ]]; then
111+
echo "[WARNING] Image $image $image_version does not match requested version $version" > /dev/stderr
112+
fi
113+
104114
echo "$image"
105115
}
106116

@@ -413,6 +423,12 @@ function image_with_sha {
413423
echo "${image_without_tag}@${digest}"
414424
}
415425

426+
function bundle_image_version {
427+
image=${1:?"Provide image"}
428+
version=$(skopeo inspect --no-tags=true "docker://${image}" | jq -r '.Labels.version')
429+
echo "${version}"
430+
}
431+
416432
function get_app_version_from_tag() {
417433
local tag app_version
418434
tag=${1:?"Provide tag for images"}

olm-catalog/serverless-operator-index/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ COPY olm-catalog/serverless-operator-index/configs /configs
1010
# Copy policy.json for opm
1111
COPY olm-catalog/serverless-operator-index/policy.json /etc/containers/policy.json
1212

13+
# Copy pre-generated yaml of bundles of the previous releases
14+
COPY olm-catalog/serverless-operator-index/index-bundles.yaml /index-bundles.yaml
15+
1316
RUN /bin/opm init serverless-operator --default-channel=stable --output yaml >> /configs/index.yaml
17+
RUN cat /index-bundles.yaml >> /configs/index.yaml
1418
RUN /bin/opm render --skip-tls-verify -o yaml \
15-
quay.io/redhat-user-workloads/ocp-serverless-tenant/serverless-operator-135/serverless-bundle:1.35.0 \
16-
quay.io/redhat-user-workloads/ocp-serverless-tenant/serverless-operator-136/serverless-bundle:1.36.0 \
17-
quay.io/redhat-user-workloads/ocp-serverless-tenant/serverless-operator-137/serverless-bundle@sha256:a081d2ca1c4825e3326e2be37e29deb84186c812d2877771a4e86580a9f5024c >> /configs/index.yaml
19+
quay.io/redhat-user-workloads/ocp-serverless-tenant/serverless-operator-137/serverless-bundle@sha256:9d6b6510a8ab953c497948af9977e8b3bf45aa3436767853af2e46af11ed7c68 >> /configs/index.yaml
1820

1921
# The base image is expected to contain
2022
# /bin/opm (with a serve subcommand) and /bin/grpc_health_probe

olm-catalog/serverless-operator-index/index-bundles.yaml

Lines changed: 334 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)