Skip to content

Commit

Permalink
Add temporary support for mce installation
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanss committed Nov 4, 2022
1 parent 2c5cb67 commit 0bdf0a2
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 2 deletions.
6 changes: 5 additions & 1 deletion agent/04_agent_configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,11 @@ EOF
function oc_mirror_mce() {
tmpimageset=$(mktemp --tmpdir "mceimageset--XXXXXXXXXX")
_tmpfiles="$_tmpfiles $tmpimageset"

# TODO: Remove this once LSO is published to the 4.12 catalog.
local version="$(openshift_version ${OCP_DIR})"
if [[ ( -n "${AGENT_DEPLOY_MCE}" ) && ( ${version} == "4.12" || ${version} == "4.13" ) ]]; then
local OPENSHIFT_RELEASE_STREAM="4.11"
fi
cat > "${tmpimageset}" << EOF
---
apiVersion: mirror.openshift.io/v1alpha2
Expand Down
74 changes: 73 additions & 1 deletion agent/05_agent_create_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,81 @@ function wait_for_cluster_ready() {
echo "Cluster is ready!"
}

function wait_for_operator() {
subscription="$1"
namespace="${2:-}"
echo "Waiting for operator ${subscription} to get installed on namespace ${namespace}..."

for _ in $(seq 1 60); do
csv=$(oc -n "${namespace}" get subscription "${subscription}" -o jsonpath='{.status.installedCSV}' || true)
if [[ -n "${csv}" ]]; then
if [[ "$(oc -n "${namespace}" get csv "${csv}" -o jsonpath='{.status.phase}')" == "Succeeded" ]]; then
echo "ClusterServiceVersion (${csv}) is ready"
return 0
fi
fi

sleep 10
done

echo "Timed out waiting for csv to become ready!"
return 1
}

function install_lso_operator_latest_available() {
local version="$(openshift_version ${OCP_DIR})"
local operator_version="4.11"
local catalog_source_name=redhat-operators-v${operator_version/./-}

if [[ ( -n "${AGENT_DEPLOY_MCE}" ) && ( ${version} == "4.12" || ${version} == "4.13" ) ]]; then
cat > "${mceManifests}/catalog_source_lso_operator.yaml" << EOF
kind: CatalogSource
apiVersion: operators.coreos.com/v1alpha1
metadata:
name: ${catalog_source_name}
namespace: openshift-marketplace
spec:
displayName: Red Hat Operators v${operator_version}
image: registry.redhat.io/redhat/redhat-operator-index:v${operator_version}
priority: -100
publisher: Red Hat
sourceType: grpc
updateStrategy:
registryPoll:
interval: 10m0s
EOF
apply_manifest "$mceManifests/catalog_source_lso_operator.yaml"
oc delete subscription local-storage-operator -n openshift-local-storage
cat > "${mceManifests}/lso_operator.yaml" << EOF
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: local-operator-group
namespace: openshift-local-storage
spec:
targetNamespaces:
- openshift-local-storage
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: local-storage-operator
namespace: openshift-local-storage
spec:
installPlanApproval: Automatic
name: local-storage-operator
source: ${catalog_source_name}
sourceNamespace: openshift-marketplace
EOF
apply_manifest "$mceManifests/lso_operator.yaml"
wait_for_operator "local-storage-operator" "openshift-local-storage"
fi
}

function mce_prepare_postinstallation_manifests() {
local mceManifests=$1

# TODO: Remove this once LSO is published to the 4.12 catalog.
install_lso_operator_latest_available
# Copy all the manifests required after the installation completed
cp ${SCRIPTDIR}/agent/assets/mce/agent_mce_1*.yaml ${mceManifests}

Expand Down

0 comments on commit 0bdf0a2

Please sign in to comment.