Skip to content

Commit fd502bd

Browse files
Ambient Code Botclaude
andcommitted
fix: handle existing RHOAI operator on a different channel
When an older RHOAI version is already installed on a different channel, OLM can't find an upgrade path and the subscription stays stuck on the old CSV. Detect channel mismatch and delete the old subscription/CSV before applying the new one. Also use currentCSV instead of installedCSV to avoid reading stale status after deletion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 70171b4 commit fd502bd

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

.github/workflows/components-build-deploy.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,28 @@ jobs:
212212
run: |
213213
oc apply -f components/manifests/components/openshift-ai/namespace.yaml
214214
oc apply -f components/manifests/components/openshift-ai/operatorgroup.yaml
215+
# Remove any existing subscription/CSV to ensure clean install on the target channel
216+
OLD_CSV=$(oc get subscription rhods-operator -n redhat-ods-operator \
217+
-o jsonpath='{.status.installedCSV}' 2>/dev/null || true)
218+
if [ -n "$OLD_CSV" ]; then
219+
DESIRED_CHANNEL=$(grep 'channel:' components/manifests/components/openshift-ai/subscription.yaml | awk '{print $2}')
220+
CURRENT_CHANNEL=$(oc get subscription rhods-operator -n redhat-ods-operator \
221+
-o jsonpath='{.spec.channel}' 2>/dev/null || true)
222+
if [ "$CURRENT_CHANNEL" != "$DESIRED_CHANNEL" ]; then
223+
echo "Channel mismatch ($CURRENT_CHANNEL → $DESIRED_CHANNEL), removing old operator..."
224+
oc delete subscription rhods-operator -n redhat-ods-operator --ignore-not-found
225+
oc delete csv "$OLD_CSV" -n redhat-ods-operator --ignore-not-found
226+
fi
227+
fi
215228
oc apply -f components/manifests/components/openshift-ai/subscription.yaml
216229
217230
- name: Wait for RHOAI operator to be ready
218231
run: |
219-
echo "Waiting for RHOAI operator CSV to appear..."
232+
DESIRED_CHANNEL=$(grep 'channel:' components/manifests/components/openshift-ai/subscription.yaml | awk '{print $2}')
233+
echo "Waiting for RHOAI operator CSV on channel $DESIRED_CHANNEL..."
220234
for i in $(seq 1 60); do
221235
CSV=$(oc get subscription rhods-operator -n redhat-ods-operator \
222-
-o jsonpath='{.status.installedCSV}' 2>/dev/null)
236+
-o jsonpath='{.status.currentCSV}' 2>/dev/null)
223237
if [ -n "$CSV" ]; then
224238
echo "Found CSV: $CSV"
225239
break

.github/workflows/prod-release-deploy.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,28 @@ jobs:
351351
run: |
352352
oc apply -f components/manifests/components/openshift-ai/namespace.yaml
353353
oc apply -f components/manifests/components/openshift-ai/operatorgroup.yaml
354+
# Remove any existing subscription/CSV to ensure clean install on the target channel
355+
OLD_CSV=$(oc get subscription rhods-operator -n redhat-ods-operator \
356+
-o jsonpath='{.status.installedCSV}' 2>/dev/null || true)
357+
if [ -n "$OLD_CSV" ]; then
358+
DESIRED_CHANNEL=$(grep 'channel:' components/manifests/components/openshift-ai/subscription.yaml | awk '{print $2}')
359+
CURRENT_CHANNEL=$(oc get subscription rhods-operator -n redhat-ods-operator \
360+
-o jsonpath='{.spec.channel}' 2>/dev/null || true)
361+
if [ "$CURRENT_CHANNEL" != "$DESIRED_CHANNEL" ]; then
362+
echo "Channel mismatch ($CURRENT_CHANNEL → $DESIRED_CHANNEL), removing old operator..."
363+
oc delete subscription rhods-operator -n redhat-ods-operator --ignore-not-found
364+
oc delete csv "$OLD_CSV" -n redhat-ods-operator --ignore-not-found
365+
fi
366+
fi
354367
oc apply -f components/manifests/components/openshift-ai/subscription.yaml
355368
356369
- name: Wait for RHOAI operator to be ready
357370
run: |
358-
echo "Waiting for RHOAI operator CSV to appear..."
371+
DESIRED_CHANNEL=$(grep 'channel:' components/manifests/components/openshift-ai/subscription.yaml | awk '{print $2}')
372+
echo "Waiting for RHOAI operator CSV on channel $DESIRED_CHANNEL..."
359373
for i in $(seq 1 60); do
360374
CSV=$(oc get subscription rhods-operator -n redhat-ods-operator \
361-
-o jsonpath='{.status.installedCSV}' 2>/dev/null)
375+
-o jsonpath='{.status.currentCSV}' 2>/dev/null)
362376
if [ -n "$CSV" ]; then
363377
echo "Found CSV: $CSV"
364378
break

0 commit comments

Comments
 (0)