Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[openshift_setup] Add support for overriding dependent operators CatalogSource #2694

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
9 changes: 9 additions & 0 deletions roles/kustomize_deploy/tasks/install_operators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@
status: "True"
wait_timeout: 300

- name: Create catalog source and switch dependent operators to consume it
when:
- cifmw_openshift_setup_enable_operator_catalog_override |
default(false) | bool
ansible.builtin.import_role:
name: openshift_setup
tasks_from: patch_dependent_operators_source.yml

Comment on lines +189 to +196
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need this call here?
If we follow what's done in that role what I'd expect is just another include_tasks at the end with cifmw_openshift_setup_enable_operator_catalog_override as a conditional and the proper default in the role defaults file.
The role runs always and before this one so we should be safe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can't validate currently because downstream CI infra is having an outage but my understanding is when the openshift_setup role runs, the subscriptions do not yet exist.

Yes I could create the CatalogSource when openshift_setup runs but I wanted to keep the logic together.

I could also create the subscriptions rather than patching them and maybe OLM wouldn't complain but this is already a nasty hack that I'm trying to minimise the footprint.

I can verify once downstream CI infra is back.

- name: Wait for controller-manager pods
kubernetes.core.k8s_info:
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
Expand All @@ -198,6 +206,7 @@
type: Ready
status: "True"
wait_timeout: 300

- name: Wait for webhook-server pods
kubernetes.core.k8s_info:
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
Expand Down
3 changes: 3 additions & 0 deletions roles/openshift_setup/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ cifmw_openshift_setup_skip_internal_registry_tls_verify: false
cifmw_openshift_setup_ca_bundle_path: "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
cifmw_openshift_setup_digest_mirrors: []
cifmw_openshift_setup_metal3_watch_all_ns: false
cifmw_openshift_setup_operator_override_catalog_name: "redhat-operators-4.17"
cifmw_openshift_setup_operator_override_catalog_namespace: "openshift-marketplace"
cifmw_openshift_setup_operator_override_catalog_image: "registry.redhat.io/redhat/redhat-operator-index:v4.17"
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
# HACK: (Lewis) This taskfile is used to test pre-release OCP versions
# by intalling the previous OCP release's catalog source for the
# dependent operators to use and overriding their subscriptions

- name: Write catalog source
kubernetes.core.k8s:
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
state: present
definition:
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: "{{ cifmw_openshift_setup_operator_override_catalog_name }}"
namespace: "{{ cifmw_openshift_setup_operator_override_catalog_namespace }}"
spec:
displayName: "{{ cifmw_openshift_setup_operator_override_catalog_name }}"
image: "{{ cifmw_openshift_setup_operator_override_catalog_image }}"
publisher: CI-Framework
sourceType: grpc
updateStrategy:
registryPoll:
interval: 10m

- name: Patch metallb operator subscription to use custom CatalogSource
kubernetes.core.k8s:
state: patched
kind: Subscription
api_version: operators.coreos.com/v1alpha1
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
name: metallb-operator-sub
namespace: metallb-system
definition:
spec:
source: "{{ cifmw_openshift_setup_operator_override_catalog_name }}"
wait: true
wait_timeout: 300
wait_condition:
type: CatalogSourcesUnhealthy
status: "False"

- name: Patch nmstate operator subscription to use custom CatalogSource
kubernetes.core.k8s:
state: patched
kind: Subscription
api_version: operators.coreos.com/v1alpha1
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
name: kubernetes-nmstate-operator
namespace: openshift-nmstate
definition:
spec:
source: "{{ cifmw_openshift_setup_operator_override_catalog_name }}"
wait_sleep: 10
wait: true
wait_timeout: 300
wait_condition:
type: CatalogSourcesUnhealthy
status: "False"