From 4d085b08de3b3c16c70ed2a84d184db0df7b51b5 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Wed, 3 Jan 2024 17:34:12 +0100 Subject: [PATCH] Add optional spec.replaces field to CSV for update graph compliance The way we generate our CSVs uses OLM's skipRange functionality. This is fine, but using only this leads to older versions becoming unavailable after the fact -- see the warning at [1]. By adding an optional spec.replaces to our CSV, we allow update testing as well as actual production updates for downstream builds that leverage it. Populating the field requires knowledge of the latest-released bundle, so we take it from an environment variable to be provided by the builder. If this is unset we don't include the spec.replaces field at all -- leaving previous behavior unchanged. Resolves #559 Related: STF-1658 [1] https://olm.operatorframework.io/docs/concepts/olm-architecture/operator-catalog/creating-an-update-graph/#skiprange --- build/generate_bundle.sh | 7 +++++++ .../service-telemetry-operator.clusterserviceversion.yaml | 1 + 2 files changed, 8 insertions(+) diff --git a/build/generate_bundle.sh b/build/generate_bundle.sh index 14a635cf5..0358c317f 100755 --- a/build/generate_bundle.sh +++ b/build/generate_bundle.sh @@ -35,6 +35,13 @@ generate_bundle() { ${OPERATOR_SDK} generate bundle --verbose --channels ${BUNDLE_CHANNELS} --default-channel ${BUNDLE_DEFAULT_CHANNEL} --manifests --metadata --version "${OPERATOR_BUNDLE_VERSION}" --output-dir "${WORKING_DIR}" >> ${LOGFILE} 2>&1 popd > /dev/null 2>&1 + # CSVs without a spec.replaces value are valid, so fall back to those if + # latest released version is unknown + if [[ -n "$BUNDLE_LATEST_RELEASED_VERSION" ]]; then + REPLACE_REGEX="$REPLACE_REGEX;s#<>#${BUNDLE_LATEST_RELEASED_VERSION}#g" + else sed -i '/<>/d' "${WORKING_DIR}/manifests/${OPERATOR_NAME}.clusterserviceversion.yaml" + fi + sed -i -E "${REPLACE_REGEX}" "${WORKING_DIR}/manifests/${OPERATOR_NAME}.clusterserviceversion.yaml" } diff --git a/deploy/olm-catalog/service-telemetry-operator/manifests/service-telemetry-operator.clusterserviceversion.yaml b/deploy/olm-catalog/service-telemetry-operator/manifests/service-telemetry-operator.clusterserviceversion.yaml index 6e758b6f3..266d41c46 100644 --- a/deploy/olm-catalog/service-telemetry-operator/manifests/service-telemetry-operator.clusterserviceversion.yaml +++ b/deploy/olm-catalog/service-telemetry-operator/manifests/service-telemetry-operator.clusterserviceversion.yaml @@ -175,6 +175,7 @@ metadata: namespace: placeholder spec: apiservicedefinitions: {} + replaces: <> customresourcedefinitions: owned: - description: Represents an instance of the Service Telemetry Framework