Skip to content

Commit b84fe51

Browse files
authored
Merge pull request #617 from bpradipt/0.1.1
Switch to Manual installPlan for OSC operator
2 parents d62f243 + c6d70db commit b84fe51

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

scripts/install-helpers/baremetal-coco/install.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ TRUSTEE_URL="${TRUSTEE_URL:-"http://kbs-service.trustee-operator-system:8080"}"
1010
CMD_TIMEOUT="${CMD_TIMEOUT:-2700}"
1111
TDX_NODE_LABEL='intel.feature.node.kubernetes.io/tdx: "true"'
1212
SNP_NODE_LABEL='amd.feature.node.kubernetes.io/snp: "true"'
13+
DEFAULT_OSC_OPERATOR_CSV=sandboxed-containers-operator.v1.8.1
1314

1415
export PCCS_API_KEY="${PCCS_API_KEY:-}"
1516
export PCCS_DB_NAME="${PCCS_DB_NAME:-database}"
@@ -19,6 +20,8 @@ export PCCS_USER_TOKEN="${PCCS_USER_TOKEN:-}"
1920
PCCS_ADMIN_TOKEN="${PCCS_ADMIN_TOKEN:-}"
2021
PCCS_PEM_CERT_PATH="${PCCS_PEM_CERT_PATH:-}"
2122

23+
OSC_OPERATOR_CSV=${OSC_OPERATOR_CSV:-$DEFAULT_OSC_OPERATOR_CSV}
24+
2225
# Function to check if a command is available
2326
function check_command() {
2427
local cmd="$1"
@@ -183,13 +186,47 @@ function wait_for_runtimeclass() {
183186
return 1
184187
}
185188

189+
# Function to approve installPlan tied to specific CSV to be available in specific namespace
190+
approve_installplan_for_target_csv() {
191+
local ns="$1"
192+
local target_csv="$2"
193+
local timeout=300
194+
local interval=5
195+
local elapsed=0
196+
197+
echo "Waiting for InstallPlan with CSV '$target_csv' in namespace '$ns'..."
198+
199+
while [ $elapsed -lt "$timeout" ]; do
200+
installplans=$(oc get installplan -n "$ns" -o jsonpath='{.items[*].metadata.name}' 2>/dev/null)
201+
for ip in $installplans; do
202+
csvs=$(oc get installplan "$ip" -n "$ns" -o jsonpath="{.spec.clusterServiceVersionNames[*]}" 2>/dev/null)
203+
for csv in $csvs; do
204+
if [ "$csv" == "$target_csv" ]; then
205+
echo "Found matching InstallPlan: $ip"
206+
echo "Approving InstallPlan: $ip"
207+
oc patch installplan "$ip" -n "$ns" -p '{"spec":{"approved":true}}' --type merge || return 1
208+
return 0
209+
fi
210+
done
211+
done
212+
sleep $interval
213+
elapsed=$((elapsed + interval))
214+
done
215+
216+
echo "Timed out waiting for InstallPlan with CSV '$target_csv' in namespace '$ns'"
217+
return 1
218+
}
219+
186220
# Function to apply the operator manifests
187221
function apply_operator_manifests() {
222+
local installplan=""
223+
188224
# Apply the manifests
189225
oc apply -f ns.yaml || return 1
190226
oc apply -f og.yaml || return 1
191227
if [[ "$GA_RELEASE" == "true" ]]; then
192228
oc apply -f subs-ga.yaml || return 1
229+
approve_installplan_for_target_csv openshift-sandboxed-containers-operator "$OSC_OPERATOR_CSV" || return 1
193230
else
194231
oc apply -f osc_catalog.yaml || return 1
195232
oc apply -f subs-upstream.yaml || return 1

scripts/install-helpers/baremetal-coco/subs-ga.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: openshift-sandboxed-containers-operator
66
spec:
77
channel: stable
8-
installPlanApproval: Automatic
8+
installPlanApproval: Manual
99
name: sandboxed-containers-operator
1010
source: redhat-operators
1111
sourceNamespace: openshift-marketplace

0 commit comments

Comments
 (0)