Skip to content

Commit cdd72f0

Browse files
Ambient Code Botclaude
andcommitted
fix: use oc apply for mlflow-db-credentials and percent-encode creds
- Replace oc create with oc apply via stdin manifest for idempotency - Percent-encode DB user/password to handle URI reserved characters - Avoids exposing credentials in process arguments Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e8a9fe9 commit cdd72f0

2 files changed

Lines changed: 38 additions & 26 deletions

File tree

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

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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: |

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

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -427,19 +427,25 @@ jobs:
427427
428428
- name: Ensure mlflow-db-credentials secret exists
429429
run: |
430-
if oc get secret mlflow-db-credentials -n redhat-ods-applications &>/dev/null; then
431-
echo "Secret already exists"
432-
else
433-
echo "Creating mlflow-db-credentials from postgresql-credentials..."
434-
DB_USER=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.user}' | base64 -d)
435-
DB_PASS=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.password}' | base64 -d)
436-
DB_HOST=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.host}' | base64 -d)
437-
DB_PORT=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.port}' | base64 -d)
438-
oc create namespace redhat-ods-applications --dry-run=client -o yaml | oc apply -f -
439-
oc create secret generic mlflow-db-credentials \
440-
-n redhat-ods-applications \
441-
--from-literal=uri="postgresql://${DB_USER}:${DB_PASS}@${DB_HOST}.ambient-code.svc.cluster.local:${DB_PORT}/mlflow?sslmode=disable"
442-
fi
430+
echo "Reconciling mlflow-db-credentials from postgresql-credentials..."
431+
DB_USER=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.user}' | base64 -d)
432+
DB_PASS=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.password}' | base64 -d)
433+
DB_HOST=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.host}' | base64 -d)
434+
DB_PORT=$(oc get secret postgresql-credentials -n ambient-code -o jsonpath='{.data.db\.port}' | base64 -d)
435+
ENC_USER=$(python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "$DB_USER")
436+
ENC_PASS=$(python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "$DB_PASS")
437+
ENCODED_URI="postgresql://${ENC_USER}:${ENC_PASS}@${DB_HOST}.ambient-code.svc.cluster.local:${DB_PORT}/mlflow?sslmode=disable"
438+
oc create namespace redhat-ods-applications --dry-run=client -o yaml | oc apply -f -
439+
oc apply -f - <<EOF
440+
apiVersion: v1
441+
kind: Secret
442+
metadata:
443+
name: mlflow-db-credentials
444+
namespace: redhat-ods-applications
445+
type: Opaque
446+
stringData:
447+
uri: "${ENCODED_URI}"
448+
EOF
443449
444450
- name: Deploy MLflow instance
445451
run: |

0 commit comments

Comments
 (0)