Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 24 additions & 27 deletions .github/workflows/operatorhub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- uses: dawidd6/action-download-artifact@1f8785ff7a5130826f848e7f72725c85d241860f
with:
name: olm
workflow: main.yaml
workflow: release.yaml
github_token: ${{ secrets.VM_BOT_GH_TOKEN }}
run_id: ${{ github.event.workflow_run.id }}
path: bundle
Expand All @@ -71,45 +71,42 @@ jobs:
run: |
if [ ! -d bundle ]; then
echo "No bundle directory found"
exit 1;
exit 1
fi
CATALOGS_DIR=__operatorhub-repo/catalogs
NEW_VERSION=$(ls bundle | head -1)
CATALOG_FILE=${CATALOGS_DIR}/latest/victoriametrics-operator/catalog.yaml
mkdir -p ${CATALOGS_DIR}/latest/victoriametrics-operator

# Save existing catalog as PREV_CATALOG before overwriting
if [ -f "${CATALOG_FILE}" ]; then
cp "${CATALOG_FILE}" /tmp/vm-prev-catalog.yaml
PREV_CATALOG=/tmp/vm-prev-catalog.yaml
fi
export OPERATOR_NAME="victoriametrics-operator"
export OPERATOR_DIR=__operatorhub-repo/operators/${OPERATOR_NAME}
mkdir -p ${OPERATOR_DIR}

PREVIOUS_VERSION=$(yq 'select(.schema == "olm.channel") | .entries[0].name' \
${PREV_CATALOG} 2>/dev/null || true)
NEW_VERSION=$(ls bundle | head -1)
export OLD_VERSION=$(find ${OPERATOR_DIR}/* ! -path "*/catalog-templates" -maxdepth 0 -type d -exec basename {} \; | sort -V -r | head -1)
export OLD_ENTRY="${OPERATOR_NAME}.v${OLD_VERSION}"

opm render bundle/${NEW_VERSION} --output=yaml > /tmp/vm-bundle-rendered.yaml
yq 'select(.schema == "olm.package")' "${PREV_CATALOG}" > /tmp/vm-catalog-header.yaml
echo "---" >> /tmp/vm-catalog-header.yaml
yq '.entries[] | select(.schema == "olm.channel")' \
bundle/${NEW_VERSION}/catalog-templates/latest.yaml >> /tmp/vm-catalog-header.yaml
if [ ! -z $OLD_VERSION ]; then
export MANIFEST_PATH=bundle/${NEW_VERSION}/manifests/victoriametrics-operator.clusterserviceversion.yaml
yq -i '.spec.replaces = "victoriametrics-operator.v" + strenv(OLD_VERSION)' $MANIFEST_PATH
fi

# Include previous bundles from PREV_CATALOG (excludes current version to avoid duplicates)
yq "select(.schema == \"olm.bundle\" and .name != \"victoriametrics-operator.v${NEW_VERSION}\")" \
"${PREV_CATALOG}" > /tmp/vm-prev-bundles.yaml
yq eval-all '.' /tmp/vm-catalog-header.yaml /tmp/vm-bundle-rendered.yaml /tmp/vm-prev-bundles.yaml > ${CATALOG_FILE}
mv bundle/${NEW_VERSION} ${OPERATOR_DIR}/
if [ -f ${OPERATOR_DIR}/Makefile ]; then
opm render ${OPERATOR_DIR}/${NEW_VERSION} --output=yaml \
| yq 'select(.schema == "olm.bundle")' > /tmp/new-bundle.yaml

if [ -n "${PREVIOUS_VERSION}" ]; then
yq -i '(select(.schema == "olm.channel") | .entries[0]).replaces = strenv(PREVIOUS_VERSION)' ${CATALOG_FILE}
for TEMPLATE in ${OPERATOR_DIR}/catalog-templates/*.yaml; do
PREV_HEAD=$(yq '.entries[] | select(.schema == "olm.channel") | .entries[-1].name' "${TEMPLATE}")
NEW_VERSION="${NEW_VERSION}" PREV_HEAD="${PREV_HEAD}" \
yq -i '(.entries[] | select(.schema == "olm.channel") | .entries) += [{"name": "victoriametrics-operator.v" + strenv(NEW_VERSION), "replaces": strenv(PREV_HEAD)}]' "${TEMPLATE}"
yq -i '.entries += [load("/tmp/new-bundle.yaml")]' "${TEMPLATE}"
done
fi
opm validate ${CATALOGS_DIR}/latest/victoriametrics-operator

echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "VERSION=${NEW_VERSION}" >> $GITHUB_OUTPUT

- name: Create Pull Request
if: ${{ steps.update.outputs.VERSION != '' }}
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
with:
add-paths: catalogs
add-paths: operators/victoriametrics-operator
commit-message: 'victoriametrics-operator: ${{ steps.update.outputs.VERSION }}'
signoff: true
committer: "Github Actions <${{ steps.import-gpg.outputs.email }}>"
Expand Down
25 changes: 4 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ build-installer: manifests generate kustomize ## Generate a consolidated YAML wi
$(KUSTOMIZE) build config/base-with-webhook > dist/install-with-webhook.yaml
$(KUSTOMIZE) build config/crd/overlay > dist/crd.yaml

olm: operator-sdk opm yq docs
olm: operator-sdk yq docs
$(eval DIGEST = $(shell $(CONTAINER_TOOL) buildx imagetools inspect $(REGISTRY)/$(ORG)/$(REPO):$(TAG)-ubi --format "{{print .Manifest.Digest}}"))
rm -rf bundle* catalog
rm -rf bundle*
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manifests && \
$(KUSTOMIZE) edit set image manager=$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)
Expand All @@ -286,27 +286,10 @@ olm: operator-sdk opm yq docs
$(OPERATOR_SDK) bundle validate ./bundle/$(VERSION)
$(YQ) -i '.metadata.annotations.containerImage = "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)" | .spec.install.spec.deployments[0].spec.template.containers[0].image = "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)" | .spec.install.spec.deployments[0].spec.template.spec.containers[0].image = "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)"' \
bundle/$(VERSION)/manifests/victoriametrics-operator.clusterserviceversion.yaml
$(YQ) -i '.annotations."com.redhat.openshift.versions" = "v4.12-v4.21"' \
$(YQ) -i '.annotations."com.redhat.openshift.versions" = "v4.12-v4.22"' \
bundle/$(VERSION)/metadata/annotations.yaml
mkdir -p bundle/$(VERSION)/catalog-templates catalog/latest
$(YQ) '.entries[] | select(.schema == "olm.channel") | .entries[] | select(.name != "victoriametrics-operator.v$(VERSION)") | .name' config/manifests/catalog-templates/latest.yaml > /tmp/vm-prev-names.txt
$(YQ) '.entries[] | select(.schema == "olm.channel") | .entries[] | select(.name != "victoriametrics-operator.v$(VERSION)") | .replaces | select(.)' config/manifests/catalog-templates/latest.yaml > /tmp/vm-prev-replaces.txt
PREV_HEAD=$$(grep -Fxvf /tmp/vm-prev-replaces.txt /tmp/vm-prev-names.txt | head -1); \
test -n "$$PREV_HEAD" || { echo "Error: could not determine previous channel head from catalog template"; exit 1; }; \
PREV_HEAD="$$PREV_HEAD" $(YQ) -i '(.entries[] | select(.schema == "olm.channel")).entries = [{"name": "victoriametrics-operator.v$(VERSION)", "replaces": strenv(PREV_HEAD)}] + (.entries[] | select(.schema == "olm.channel") | .entries | map(select(.name != "victoriametrics-operator.v$(VERSION)")))' \
config/manifests/catalog-templates/latest.yaml; \
PREV_HEAD="$$PREV_HEAD" $(YQ) -i '.spec.relatedImages = [{"name": "victoriametrics-operator", "image": "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)"}] | .spec.replaces = strenv(PREV_HEAD)' \
$(YQ) -i '.spec.relatedImages = [{"name": "victoriametrics-operator", "image": "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)"}]' \
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The generated CSV no longer sets spec.replaces, which can break OLM upgrade paths between operator versions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Makefile, line 291:

<comment>The generated CSV no longer sets `spec.replaces`, which can break OLM upgrade paths between operator versions.</comment>

<file context>
@@ -286,27 +286,10 @@ olm: operator-sdk opm yq docs
-	PREV_HEAD="$$PREV_HEAD" $(YQ) -i '(.entries[] | select(.schema == "olm.channel")).entries = [{"name": "victoriametrics-operator.v$(VERSION)", "replaces": strenv(PREV_HEAD)}] + (.entries[] | select(.schema == "olm.channel") | .entries | map(select(.name != "victoriametrics-operator.v$(VERSION)")))' \
-		config/manifests/catalog-templates/latest.yaml; \
-	PREV_HEAD="$$PREV_HEAD" $(YQ) -i '.spec.relatedImages = [{"name": "victoriametrics-operator", "image": "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)"}] | .spec.replaces = strenv(PREV_HEAD)' \
+	$(YQ) -i '.spec.relatedImages = [{"name": "victoriametrics-operator", "image": "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)"}]' \
 		bundle/$(VERSION)/manifests/victoriametrics-operator.clusterserviceversion.yaml
-	cp config/manifests/catalog-templates/latest.yaml bundle/$(VERSION)/catalog-templates/latest.yaml
</file context>
Fix with Cubic

bundle/$(VERSION)/manifests/victoriametrics-operator.clusterserviceversion.yaml
cp config/manifests/catalog-templates/latest.yaml bundle/$(VERSION)/catalog-templates/latest.yaml
{ $(YQ) '.entries[] | select(.schema == "olm.package")' \
bundle/$(VERSION)/catalog-templates/latest.yaml; \
echo "---"; \
$(YQ) '(.entries[] | select(.schema == "olm.channel")) | .entries = [.entries[0]]' \
bundle/$(VERSION)/catalog-templates/latest.yaml; \
$(OPM) render bundle/$(VERSION) --output=yaml | \
$(YQ) '(select(.schema == "olm.bundle") | .image) = "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)" | (select(.schema == "olm.bundle") | .relatedImages) = [{"name": "victoriametrics-operator", "image": "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)"}]'; \
} > catalog/latest/catalog.yaml
$(OPM) validate catalog/latest

##@ Deployment

Expand Down
71 changes: 0 additions & 71 deletions config/manifests/catalog-templates/latest.yaml

This file was deleted.

Loading