Skip to content

Commit 18c67cb

Browse files
Ambient Code Botclaude
andcommitted
fix: auto-create mlflow-db-credentials from existing postgresql-credentials
Instead of failing when the mlflow-db-credentials secret is missing, construct it from the existing postgresql-credentials secret in the ambient-code namespace. This avoids requiring manual secret setup on each cluster. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fd502bd commit 18c67cb

2 files changed

Lines changed: 30 additions & 44 deletions

File tree

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

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -212,28 +212,14 @@ 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
228215
oc apply -f components/manifests/components/openshift-ai/subscription.yaml
229216
230217
- name: Wait for RHOAI operator to be ready
231218
run: |
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..."
219+
echo "Waiting for RHOAI operator CSV to appear..."
234220
for i in $(seq 1 60); do
235221
CSV=$(oc get subscription rhods-operator -n redhat-ods-operator \
236-
-o jsonpath='{.status.currentCSV}' 2>/dev/null)
222+
-o jsonpath='{.status.installedCSV}' 2>/dev/null)
237223
if [ -n "$CSV" ]; then
238224
echo "Found CSV: $CSV"
239225
break
@@ -294,13 +280,20 @@ jobs:
294280
|| oc exec -n ambient-code deploy/postgresql -- \
295281
psql -U postgres -c "CREATE DATABASE mlflow"
296282
297-
- name: Verify mlflow-db-credentials secret exists
283+
- name: Ensure mlflow-db-credentials secret exists
298284
run: |
299-
if ! oc get secret mlflow-db-credentials -n redhat-ods-applications &>/dev/null; then
300-
echo "::error::Secret mlflow-db-credentials not found in redhat-ods-applications."
301-
echo "::error::Create it before applying the MLflow resource."
302-
echo "::error::See components/manifests/base/mlflow-db-credentials-secret.yaml.example"
303-
exit 1
285+
if oc get secret mlflow-db-credentials -n redhat-ods-applications &>/dev/null; then
286+
echo "Secret already exists"
287+
else
288+
echo "Creating mlflow-db-credentials from postgresql-credentials..."
289+
DB_USER=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.user}' | base64 -d)
290+
DB_PASS=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.password}' | base64 -d)
291+
DB_HOST=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.host}' | base64 -d)
292+
DB_PORT=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.port}' | base64 -d)
293+
oc create namespace redhat-ods-applications --dry-run=client -o yaml | oc apply -f -
294+
oc create secret generic mlflow-db-credentials \
295+
-n redhat-ods-applications \
296+
--from-literal=uri="postgresql://${DB_USER}:${DB_PASS}@${DB_HOST}.ambient-code.svc.cluster.local:${DB_PORT}/mlflow?sslmode=disable"
304297
fi
305298
306299
- name: Deploy MLflow instance

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

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -351,28 +351,14 @@ 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
367354
oc apply -f components/manifests/components/openshift-ai/subscription.yaml
368355
369356
- name: Wait for RHOAI operator to be ready
370357
run: |
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..."
358+
echo "Waiting for RHOAI operator CSV to appear..."
373359
for i in $(seq 1 60); do
374360
CSV=$(oc get subscription rhods-operator -n redhat-ods-operator \
375-
-o jsonpath='{.status.currentCSV}' 2>/dev/null)
361+
-o jsonpath='{.status.installedCSV}' 2>/dev/null)
376362
if [ -n "$CSV" ]; then
377363
echo "Found CSV: $CSV"
378364
break
@@ -433,13 +419,20 @@ jobs:
433419
|| oc exec -n ambient-code deploy/postgresql -- \
434420
psql -U postgres -c "CREATE DATABASE mlflow"
435421
436-
- name: Verify mlflow-db-credentials secret exists
422+
- name: Ensure mlflow-db-credentials secret exists
437423
run: |
438-
if ! oc get secret mlflow-db-credentials -n redhat-ods-applications &>/dev/null; then
439-
echo "::error::Secret mlflow-db-credentials not found in redhat-ods-applications."
440-
echo "::error::Create it before applying the MLflow resource."
441-
echo "::error::See components/manifests/base/mlflow-db-credentials-secret.yaml.example"
442-
exit 1
424+
if oc get secret mlflow-db-credentials -n redhat-ods-applications &>/dev/null; then
425+
echo "Secret already exists"
426+
else
427+
echo "Creating mlflow-db-credentials from postgresql-credentials..."
428+
DB_USER=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.user}' | base64 -d)
429+
DB_PASS=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.password}' | base64 -d)
430+
DB_HOST=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.host}' | base64 -d)
431+
DB_PORT=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.port}' | base64 -d)
432+
oc create namespace redhat-ods-applications --dry-run=client -o yaml | oc apply -f -
433+
oc create secret generic mlflow-db-credentials \
434+
-n redhat-ods-applications \
435+
--from-literal=uri="postgresql://${DB_USER}:${DB_PASS}@${DB_HOST}.ambient-code.svc.cluster.local:${DB_PORT}/mlflow?sslmode=disable"
443436
fi
444437
445438
- name: Deploy MLflow instance

0 commit comments

Comments
 (0)