Skip to content

Commit

Permalink
Allow catalog operator removal action
Browse files Browse the repository at this point in the history
With this commit operator owners are able to remove an operator from a
catalog. The removal process is handled by the IIB endpoint and is only
supported for FBC operators.

JIRA: ISV-5139

Signed-off-by: Ales Raszka <[email protected]>
  • Loading branch information
Allda committed Aug 13, 2024
1 parent 80d88cc commit a4ab39d
Show file tree
Hide file tree
Showing 20 changed files with 850 additions and 252 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ deploy-playground:
@echo "Deploying playground..."
ansible-playbook \
ansible/playbooks/deploy.yml \
--inventory ansible/inventory/operator-pipeline-stage \
-e oc_namespace=$(USER)-playground \
-e integration_tests_operator_bundle_version=$(OPERATOR_VERSION) \
-e operator_pipeline_image_pull_spec=$(PIPELINE_IMAGE) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,21 +434,16 @@ spec:
name: validate-catalog-format
kind: Task
runAfter:
# This is just a temporary location until we have a proper
# FCB branch based on config
- resolve-pr-type
when:
- &catalogFileChange
input: "$(tasks.detect-changes.results.affected_catalogs)"
- input: "$(tasks.detect-changes.results.added_or_modified_catalogs)"
operator: notin
values: [""]
params:
- name: pipeline_image
value: "$(params.pipeline_image)"
- name: affected_catalogs
value: "$(tasks.detect-changes.results.affected_catalogs)"
- name: operator_path
value: "$(tasks.detect-changes.results.operator_path)"
value: "$(tasks.detect-changes.results.added_or_modified_catalogs)"
workspaces:
- name: source
workspace: repository
Expand All @@ -459,18 +454,19 @@ spec:
name: build-fragment-images
kind: Task
runAfter:
# This is just a temporary location until we have a proper
# FCB branch based on config
- validate-catalog-format
when:
- *catalogFileChange
- &catalogFileChange
input: "$(tasks.detect-changes.results.added_or_modified_catalogs)"
operator: notin
values: [""]
params:
- name: pipeline_image
value: "$(params.pipeline_image)"
- name: commit_sha
value: $(params.git_commit)
- name: affected_catalogs
value: "$(tasks.detect-changes.results.affected_catalogs)"
value: "$(tasks.detect-changes.results.catalogs_with_added_or_modified_operators)"
- name: fragment_repository
value: "$(params.registry)/$(params.image_namespace)/catalog"
workspaces:
Expand Down Expand Up @@ -845,24 +841,24 @@ spec:
workspace: repository
subPath: src

- name: add-fbc-fragments-to-index
- name: build-fbc-index-images
runAfter:
# This is just a temporary location until we have a proper
# FCB branch based on config
- get-supported-versions
when:
- *catalogFileChange
taskRef:
name: add-fbc-fragments-to-index
name: build-fbc-index-images
params:
- name: pipeline_image
value: "$(params.pipeline_image)"
- name: index_images
value: "$(tasks.get-supported-versions.results.indices)"
- name: commit_sha
value: "$(params.git_commit)"
- name: affected_catalogs
value: "$(tasks.detect-changes.results.affected_catalogs)"
- name: catalogs_with_added_or_modified_operators
value: "$(tasks.detect-changes.results.catalogs_with_added_or_modified_operators)"
- name: deleted_catalog_operators
value: "$(tasks.detect-changes.results.deleted_catalog_operators)"
- name: image_repository
value: "$(params.registry)/$(params.image_namespace)/catalog"
- name: iib_url
Expand All @@ -881,7 +877,7 @@ spec:
# Build new temporary index using IIB
- name: add-bundle-to-index
runAfter:
- add-fbc-fragments-to-index
- build-fbc-index-images
when:
# Run only when a bundle is added and it doesn't use FBC
- *bundleAdded
Expand Down Expand Up @@ -921,7 +917,7 @@ spec:

- name: build-fbc-scratch-catalog
runAfter:
- add-fbc-fragments-to-index
- build-fbc-index-images
when:
# Run only when a bundle is added and it uses FBC
- *bundleAdded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,6 @@ spec:
name: build-fragment-images
kind: Task
runAfter:
# This is just a temporary location until we have a proper
# FCB branch based on config
- get-supported-versions
when:
- &catalogUpdated
Expand All @@ -448,7 +446,7 @@ spec:
- name: commit_sha
value: $(params.git_commit)
- name: affected_catalogs
value: "$(tasks.detect-changes.results.affected_catalogs)"
value: "$(tasks.detect-changes.results.catalogs_with_added_or_modified_operators)"
- name: fragment_repository
value: "$(params.registry)/$(params.image_namespace)/catalog"
workspaces:
Expand Down Expand Up @@ -479,26 +477,26 @@ spec:
- name: lease-owner
value: "$(context.pipelineRun.name)"

- name: add-fbc-fragments-to-index
- name: build-fbc-index-images
runAfter:
# This is just a temporary location until we have a proper
# FCB branch based on config
- acquire-lease
when:
- *catalogUpdated
- *notUndistributed
- *isFBC
taskRef:
name: add-fbc-fragments-to-index
name: build-fbc-index-images
params:
- name: pipeline_image
value: "$(params.pipeline_image)"
- name: index_images
value: "$(tasks.get-supported-versions.results.indices)"
- name: commit_sha
value: "$(params.git_commit)"
- name: affected_catalogs
value: "$(tasks.detect-changes.results.affected_catalogs)"
- name: catalogs_with_added_or_modified_operators
value: "$(tasks.detect-changes.results.catalogs_with_added_or_modified_operators)"
- name: deleted_catalog_operators
value: "$(tasks.detect-changes.results.deleted_catalog_operators)"
- name: image_repository
value: "$(params.registry)/$(params.image_namespace)/catalog"
- name: iib_url
Expand All @@ -517,7 +515,7 @@ spec:
# call IIB to add the bundle to index
- name: add-bundle-to-index
runAfter:
- add-fbc-fragments-to-index
- build-fbc-index-images
when:
- *catalogUpdated
- *notUndistributed
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: build-fbc-index-images
spec:
description: |-
This task handles a process of updating index images by applying FBC
fragments (added or modified operators) and removing operators from
he index (deleted operators).
Both of these operations are supported in the FBC workflow.
params:
- name: pipeline_image

- name: index_images
description: All known supported index image pull specs (space separated)

- name: commit_sha
description: SHA of the commit to set the tag suffix.

- name: catalogs_with_added_or_modified_operators
description: Comma separated list of catalogs with added or modified operators

- name: deleted_catalog_operators
description: |
Comma separated list of operators deleted from the catalogs
directory structure
- name: image_repository
description: A repository where fragments are stored

- name: iib_url
description: IIB API url
default: https://iib.engineering.redhat.com

- name: environment
description: |
Which environment the pipeline is running in. Can be one of [dev, qa, stage, prod]
- name: kerberos_keytab_secret_name
description: >-
The name of the Kubernetes Secret that contains the kerberos keytab for submitting IIB builds.
- name: kerberos_keytab_secret_key
description: >-
The key within the Kubernetes Secret that contains the kerberos keytab for submitting IIB builds.
volumes:
- name: kerberos-volume
secret:
secretName: "$(params.kerberos_keytab_secret_name)"
workspaces:
- name: output

steps:
- name: add-fbc-fragments-to-index
image: "$(params.pipeline_image)"
workingDir: $(workspaces.output.path)
env:
- name: KRB_KEYTAB_FILE
value: "/etc/kerberos/$(params.kerberos_keytab_secret_key)"
volumeMounts:
- name: kerberos-volume
readOnly: true
mountPath: "/etc/kerberos"
script: |
#! /usr/bin/env bash
set -xe
if [[ "$(params.catalogs_with_added_or_modified_operators)" == "" ]];then
echo "No affected catalogs, skipping fragment image build"
exit 0
fi
ENV=$(params.environment)
INDEX_IMAGES="$(params.index_images)"
if [[ $ENV == "dev" || $ENV == "qa" ]]; then
echo "Adding FBC fragment to an index is a NOOP for dev and qa environments at this time."
exit 0
fi
if [[ $ENV != "prod" ]]; then
# Replace registry urls with stage urls when in preprod
INDEX_IMAGES=${INDEX_IMAGES//registry.redhat.io/registry.stage.redhat.io}
fi
add-fbc-fragments-to-index \
--iib-url "$(params.iib_url)" \
--indices $INDEX_IMAGES \
--catalog-names "$(params.catalogs_with_added_or_modified_operators)" \
--image-repository "$(params.image_repository)" \
--commit-sha "$(params.commit_sha)" \
--image-output fbc-index-image-paths.txt \
--verbose
cat fbc-index-image-paths.txt
- name: rm-operator-from-index
image: "$(params.pipeline_image)"
workingDir: $(workspaces.output.path)
env:
- name: KRB_KEYTAB_FILE
value: "/etc/kerberos/$(params.kerberos_keytab_secret_key)"
volumeMounts:
- name: kerberos-volume
readOnly: true
mountPath: "/etc/kerberos"
script: |
#! /usr/bin/env bash
set -xe
if [[ "$(params.deleted_catalog_operators)" == "" ]];then
echo "No deleted operators, skipping operator removal from index"
exit 0
fi
ENV=$(params.environment)
INDEX_IMAGES="$(params.index_images)"
if [[ $ENV == "dev" || $ENV == "qa" ]]; then
echo "Adding FBC fragment to an index is a NOOP for dev and qa environments at this time."
exit 0
fi
if [[ $ENV != "prod" ]]; then
# Replace registry urls with stage urls when in preprod
INDEX_IMAGES=${INDEX_IMAGES//registry.redhat.io/registry.stage.redhat.io}
fi
rm-operator-from-index \
--iib-url "$(params.iib_url)" \
--indices $INDEX_IMAGES \
--fragment-builds-output fbc-index-image-paths.txt \
--rm-catalog-operators "$(params.deleted_catalog_operators)" \
--image-output fbc-index-image-paths.txt \
--verbose
cat fbc-index-image-paths.txt
Loading

0 comments on commit a4ab39d

Please sign in to comment.