From be7658ba2bae758f36dbabec56f85c1c64513b7b Mon Sep 17 00:00:00 2001 From: Daniel Pawlik Date: Tue, 10 Feb 2026 09:01:15 +0100 Subject: [PATCH 1/2] [openshift_setup] Recreate all openshift-marketplace containers by default The CI jobs fails because they are waiting for openshift-marketplace. Let's make sure openshift-marketplace all pods are recreated before continue. It should help avoid potential issues on outdated OCP cluster versions. Signed-off-by: Daniel Pawlik --- roles/openshift_setup/defaults/main.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/roles/openshift_setup/defaults/main.yml b/roles/openshift_setup/defaults/main.yml index 0acb47393..946b60843 100644 --- a/roles/openshift_setup/defaults/main.yml +++ b/roles/openshift_setup/defaults/main.yml @@ -27,4 +27,9 @@ cifmw_openshift_setup_digest_mirrors: [] 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" -cifmw_openshift_setup_apply_marketplace_fix: false +# NOTE(dpawlik): To avoid potential errors, where: +# oc wait pod --all --for=condition=Ready -n openshift-marketplace --timeout=1m +# never pass or operatorhub does not show any items or +# other errors like: " installPlanRef not found - subscription resolution may have failed" +# let's clean the marketplace each time. +cifmw_openshift_setup_apply_marketplace_fix: true From 69664870753f6556bfa56c6f69f550c5f170adf9 Mon Sep 17 00:00:00 2001 From: Daniel Pawlik Date: Tue, 10 Feb 2026 09:03:16 +0100 Subject: [PATCH 2/2] [openshift_setup] Create cron to recreate openshift-marketplace pods The CI jobs fails because they are waiting for openshift-marketplace. It seems that in some jobs when it is executed just once, the issue still appears after a while. Therefor we create a crontab job that would be executed each 5 minutes, that verify marketplace state and if it is not stable, would remove them. It should help avoid potential issues on outdated OCP cluster versions. Signed-off-by: Daniel Pawlik --- roles/openshift_setup/defaults/main.yml | 2 + .../files/marketplace-crontab.yml | 72 +++++++++++++++++++ .../tasks/fix_openshift_marketplace.yml | 58 ++++++++++----- 3 files changed, 113 insertions(+), 19 deletions(-) create mode 100644 roles/openshift_setup/files/marketplace-crontab.yml diff --git a/roles/openshift_setup/defaults/main.yml b/roles/openshift_setup/defaults/main.yml index 946b60843..e3d9d95a5 100644 --- a/roles/openshift_setup/defaults/main.yml +++ b/roles/openshift_setup/defaults/main.yml @@ -33,3 +33,5 @@ cifmw_openshift_setup_operator_override_catalog_image: "registry.redhat.io/redha # other errors like: " installPlanRef not found - subscription resolution may have failed" # let's clean the marketplace each time. cifmw_openshift_setup_apply_marketplace_fix: true +cifmw_openshift_setup_marketplace_oneshot: false +cifmw_openshift_setup_marketplace_crontab: true diff --git a/roles/openshift_setup/files/marketplace-crontab.yml b/roles/openshift_setup/files/marketplace-crontab.yml new file mode 100644 index 000000000..f7b1eeb8e --- /dev/null +++ b/roles/openshift_setup/files/marketplace-crontab.yml @@ -0,0 +1,72 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: cifmw-marketplace-fix +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: cifmw-marketplace-fix-sa + namespace: cifmw-marketplace-fix +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: cifmw-marketplace-fix-role +rules: + - apiGroups: [""] + resources: ["pods", "pods/log"] + verbs: ["get", "list", "watch", "delete"] + - apiGroups: [""] + resources: ["pods"] + verbs: ["create"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: cifmw-marketplace-fix-binding +subjects: + - kind: ServiceAccount + name: cifmw-marketplace-fix-sa + namespace: cifmw-marketplace-fix +roleRef: + kind: ClusterRole + name: cifmw-marketplace-fix-role + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: cifmw-marketplace-fix-cron + namespace: cifmw-marketplace-fix +spec: + schedule: "*/5 * * * *" + concurrencyPolicy: Forbid + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 3 + jobTemplate: + spec: + backoffLimit: 0 + template: + spec: + serviceAccountName: cifmw-marketplace-fix-sa + restartPolicy: Never + containers: + - name: cifmw-fix-marketplace + image: registry.redhat.io/openshift4/ose-cli:latest + command: ["/bin/bash", "-c"] + args: + - | + set -euo pipefail + + echo "Checking if all pods in openshift-marketplace are Ready..." + if oc wait pod --all --for=condition=Ready -n openshift-marketplace --timeout=1m; then + echo "All pods are Ready - nothing to do." + exit 0 + else + echo "Timeout or not all pods Ready, restarting marketplace pods..." + oc delete pods --all -n openshift-marketplace --grace-period=30 || true + echo "Delete command executed." + exit 1 + fi diff --git a/roles/openshift_setup/tasks/fix_openshift_marketplace.yml b/roles/openshift_setup/tasks/fix_openshift_marketplace.yml index 2096cfd05..4c8eeb3eb 100644 --- a/roles/openshift_setup/tasks/fix_openshift_marketplace.yml +++ b/roles/openshift_setup/tasks/fix_openshift_marketplace.yml @@ -11,23 +11,43 @@ - not cifmw_openshift_setup_dry_run - cifmw_openshift_setup_apply_marketplace_fix block: - - name: Delete the pods from openshift-marketplace namespace - kubernetes.core.k8s: - kind: Pod - state: absent - delete_all: true - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" - namespace: openshift-marketplace + - name: Execute marketplace fix once + when: cifmw_openshift_setup_marketplace_oneshot + block: + - name: Delete the pods from openshift-marketplace namespace + kubernetes.core.k8s: + kind: Pod + state: absent + delete_all: true + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" + namespace: openshift-marketplace - - name: Wait for openshift-marketplace pods to be running - environment: - KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" - PATH: "{{ cifmw_path }}" - ansible.builtin.command: - cmd: >- - oc wait pod --all --for=condition=Ready - -n openshift-marketplace --timeout=1m - register: _pod_status - retries: 4 - delay: 10 - until: _pod_status.rc == 0 + - name: Wait for openshift-marketplace pods to be running + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + ansible.builtin.command: + cmd: >- + oc wait pod --all --for=condition=Ready + -n openshift-marketplace --timeout=1m + register: _pod_status + retries: 4 + delay: 10 + until: _pod_status.rc == 0 + + - name: Execute marketplace fix via crontab + when: cifmw_openshift_setup_marketplace_crontab + block: + - name: Copy marketplace-crontab.yml manifest + ansible.builtin.copy: + src: marketplace-crontab.yml + dest: /tmp/marketplace-crontab.yml + mode: "0644" + + - name: Apply marketplace-crontab.yml manifest + ansible.builtin.command: | + oc apply -f /tmp/marketplace-crontab.yml + changed_when: false + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}"