@@ -288,19 +288,25 @@ jobs:
288288
289289 - name : Ensure mlflow-db-credentials secret exists
290290 run : |
291- if oc get secret mlflow-db-credentials -n redhat-ods-applications &>/dev/null; then
292- echo "Secret already exists"
293- else
294- echo "Creating mlflow-db-credentials from postgresql-credentials..."
295- DB_USER=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.user}' | base64 -d)
296- DB_PASS=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.password}' | base64 -d)
297- DB_HOST=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.host}' | base64 -d)
298- DB_PORT=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.port}' | base64 -d)
299- oc create namespace redhat-ods-applications --dry-run=client -o yaml | oc apply -f -
300- oc create secret generic mlflow-db-credentials \
301- -n redhat-ods-applications \
302- --from-literal=uri="postgresql://${DB_USER}:${DB_PASS}@${DB_HOST}.ambient-code.svc.cluster.local:${DB_PORT}/mlflow?sslmode=disable"
303- fi
291+ echo "Reconciling mlflow-db-credentials from postgresql-credentials..."
292+ DB_USER=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.user}' | base64 -d)
293+ DB_PASS=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.password}' | base64 -d)
294+ DB_HOST=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.host}' | base64 -d)
295+ DB_PORT=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.port}' | base64 -d)
296+ ENC_USER=$(python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "$DB_USER")
297+ ENC_PASS=$(python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "$DB_PASS")
298+ ENCODED_URI="postgresql://${ENC_USER}:${ENC_PASS}@${DB_HOST}.ambient-code.svc.cluster.local:${DB_PORT}/mlflow?sslmode=disable"
299+ oc create namespace redhat-ods-applications --dry-run=client -o yaml | oc apply -f -
300+ oc apply -f - <<EOF
301+ apiVersion: v1
302+ kind: Secret
303+ metadata:
304+ name: mlflow-db-credentials
305+ namespace: redhat-ods-applications
306+ type: Opaque
307+ stringData:
308+ uri: "${ENCODED_URI}"
309+ EOF
304310
305311 - name : Deploy MLflow instance
306312 run : |
0 commit comments