Skip to content

Commit 44992af

Browse files
authored
Merge pull request #147 from bpradipt/0.1.1
Switch to Manual installPlan for Trustee operator
2 parents 8aee736 + 4902f21 commit 44992af

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

scripts/install-helpers/install.sh

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ if [ -n "$ITA_KEY" ]; then
1111
TDX=true
1212
fi
1313
DEFAULT_IMAGE=quay.io/openshift_sandboxed_containers/kbs:v0.10.1
14+
DEFAULT_TRUSTEE_OPERATOR_CSV=trustee-operator.v0.2.0
15+
1416
if [ -n "$ITA_KEY" ]; then
1517
DEFAULT_IMAGE+="-ita"
1618
fi
19+
1720
TRUSTEE_IMAGE=${TRUSTEE_IMAGE:-$DEFAULT_IMAGE}
21+
TRUSTEE_OPERATOR_CSV=${TRUSTEE_OPERATOR_CSV:-$DEFAULT_TRUSTEE_OPERATOR_CSV}
1822

1923
# Function to check if the oc command is available
2024
function check_oc() {
@@ -105,6 +109,37 @@ function wait_for_mcp() {
105109

106110
}
107111

112+
# Function to approve installPlan tied to specific CSV to be available in specific namespace
113+
approve_installplan_for_target_csv() {
114+
local ns="$1"
115+
local target_csv="$2"
116+
local timeout=300
117+
local interval=5
118+
local elapsed=0
119+
120+
echo "Waiting for InstallPlan with CSV '$target_csv' in namespace '$ns'..."
121+
122+
while [ $elapsed -lt "$timeout" ]; do
123+
installplans=$(oc get installplan -n "$ns" -o jsonpath='{.items[*].metadata.name}' 2>/dev/null)
124+
for ip in $installplans; do
125+
csvs=$(oc get installplan "$ip" -n "$ns" -o jsonpath="{.spec.clusterServiceVersionNames[*]}" 2>/dev/null)
126+
for csv in $csvs; do
127+
if [ "$csv" == "$target_csv" ]; then
128+
echo "Found matching InstallPlan: $ip"
129+
echo "Approving InstallPlan: $ip"
130+
oc patch installplan "$ip" -n "$ns" -p '{"spec":{"approved":true}}' --type merge || return 1
131+
return 0
132+
fi
133+
done
134+
done
135+
sleep $interval
136+
elapsed=$((elapsed + interval))
137+
done
138+
139+
echo "Timed out waiting for InstallPlan with CSV '$target_csv' in namespace '$ns'"
140+
return 1
141+
}
142+
108143
# Function to set additional cluster-wide image pull secret
109144
# Requires PULL_SECRET_JSON environment variable to be set
110145
# eg. PULL_SECRET_JSON='{"my.registry.io": {"auth": "ABC"}}'
@@ -210,6 +245,7 @@ function apply_operator_manifests() {
210245
oc apply -f og.yaml || return 1
211246
if [[ "$GA_RELEASE" == "true" ]]; then
212247
oc apply -f subs-ga.yaml || return 1
248+
approve_installplan_for_target_csv trustee-operator-system "$TRUSTEE_OPERATOR_CSV" || return 1
213249
else
214250
oc apply -f trustee_catalog.yaml || return 1
215251
oc apply -f subs-upstream.yaml || return 1
@@ -363,9 +399,6 @@ check_oc || exit 1
363399
# Check if openssl command is available
364400
check_openssl || exit 1
365401

366-
# Apply the operator manifests
367-
apply_operator_manifests || exit 1
368-
369402
# If MIRRORING is true, then create the image mirroring config
370403
if [ "$MIRRORING" = true ]; then
371404
echo "Creating image mirroring config"

scripts/install-helpers/subs-ga.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ metadata:
66
namespace: trustee-operator-system
77
spec:
88
channel: stable
9-
installPlanApproval: Automatic
9+
installPlanApproval: Manual
1010
name: trustee-operator
1111
source: redhat-operators
1212
sourceNamespace: openshift-marketplace
13+
startingCSV: trustee-operator.v0.2.0

0 commit comments

Comments
 (0)