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

validate OCP marketplace #814

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ ${1}: export OPENSTACK_BRANCH=${OPENSTACK_BRANCH}
${1}: export OPENSTACK_COMMIT_HASH=${OPENSTACK_COMMIT_HASH}
${1}: export GIT_CLONE_OPTS=${GIT_CLONE_OPTS}
${1}: export CHECKOUT_FROM_OPENSTACK_REF=${CHECKOUT_FROM_OPENSTACK_REF}
${1}: export TIMEOUT=$(TIMEOUT)
endef

.PHONY: all
Expand Down Expand Up @@ -669,7 +670,8 @@ endif

##@ OPENSTACK

OPENSTACK_PREP_DEPS := $(if $(findstring true,$(INSTALL_CERT_MANAGER)), certmanager)
OPENSTACK_PREP_DEPS := validate_marketplace
OPENSTACK_PREP_DEPS += $(if $(findstring true,$(INSTALL_CERT_MANAGER)), certmanager)
OPENSTACK_PREP_DEPS += $(if $(findstring true,$(NETWORK_ISOLATION)), nmstate nncp netattach metallb metallb_config)
OPENSTACK_PREP_DEPS += $(if $(findstring true,$(NETWORK_BGP)), nmstate nncp netattach metallb metallb_config)
OPENSTACK_PREP_DEPS += $(if $(findstring true,$(BMO_SETUP)), crc_bmo_setup)
Expand Down Expand Up @@ -2548,3 +2550,8 @@ certmanager_cleanup:
oc delete -n ${OPERATOR_NAMESPACE} csv --all --ignore-not-found=true
oc delete -n ${NAMESPACE} installplan --all --ignore-not-found=true
oc delete -n cert-manager deployment --all

.PHONY: validate_marketplace
validate_marketplace: ## validates that the openshift marketplace is healthy and has the packagemanifests for the required operators
$(eval $(call vars,$@,openshift-marketplace))
bash scripts/validate-marketplace.sh
49 changes: 49 additions & 0 deletions scripts/validate-marketplace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
#
# Copyright 2024 Red Hat Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -x

if [ -z "${TIMEOUT}" ]; then
echo "Please set TIMEOUT"; exit 1
fi

OPERATOR_NAMESPACE=openshift-marketplace

oc get pods -n ${OPERATOR_NAMESPACE} | grep "CrashLoopBackOff"
if [ $? -eq 0 ]; then
oc patch OperatorHub cluster --type json -p '[{"op": "add", "path": "/spec/disableAllDefaultSources", "value": true}]'
oc wait pod --for=delete -n ${OPERATOR_NAMESPACE} -l olm.managed --timeout=${TIMEOUT}
oc patch OperatorHub cluster --type json -p '[{"op": "add", "path": "/spec/disableAllDefaultSources", "value": false}]'
oc wait pod -n ${OPERATOR_NAMESPACE} -l olm.managed --for condition=Ready
fi

OPERATORS="openshift-cert-manager-operator kubernetes-nmstate-operator metallb-operator"

for operator in $OPERATORS; do
n=0
retries="${1:-20}" # Number of retries with a default value of 20
while true; do
oc get packagemanifests -n ${OPERATOR_NAMESPACE} | grep $operator
if [ $? -eq 0 ]; then
break
fi
n=$((n+1))
if (( n >= retries )); then
echo "Failed to get packagemanifest for operator $operator. Aborting"
exit 1
fi
sleep 10
done
done