From 53d86cd48b306784322f7275db0bc68e478859e8 Mon Sep 17 00:00:00 2001 From: Sagar Patil Date: Thu, 9 Apr 2026 16:40:49 +0530 Subject: [PATCH] fix: use configurable db username in dbinit job instead of hardcoded root Root user doesn't have access on external DB. Now uses the same database username helper as the main deployment. Co-Authored-By: Claude Opus 4.6 (1M context) --- hades/templates/job-dbinit.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hades/templates/job-dbinit.yaml b/hades/templates/job-dbinit.yaml index 71311d8..0c8f584 100644 --- a/hades/templates/job-dbinit.yaml +++ b/hades/templates/job-dbinit.yaml @@ -50,12 +50,12 @@ spec: - name: MYSQL_DATABASE value: {{ include "hades.databaseName" . | quote }} - name: MYSQL_USER - value: "root" + value: {{ include "hades.databaseUsername" . | quote }} - name: MYSQL_PWD valueFrom: secretKeyRef: name: {{ include "hades.databaseSecretName" . }} - key: mysql-root-password + key: mysql-password command: - /bin/bash - -c @@ -72,7 +72,7 @@ spec: # Test connection echo "Testing database connection..." - if ! mysql -h"${MYSQL_HOST}" -P"${MYSQL_PORT}" -u"root" -e "SELECT 1" "${MYSQL_DATABASE}" &> /dev/null; then + if ! mysql -h"${MYSQL_HOST}" -P"${MYSQL_PORT}" -u"${MYSQL_USER}" -e "SELECT 1" "${MYSQL_DATABASE}" &> /dev/null; then echo "ERROR: Cannot connect to database" exit 1 fi @@ -94,7 +94,7 @@ spec: echo -n "Applying $filename... " - if mysql -h"${MYSQL_HOST}" -P"${MYSQL_PORT}" -u"root" "${MYSQL_DATABASE}" < "$sql_file" 2>/tmp/migration_error.log; then + if mysql -h"${MYSQL_HOST}" -P"${MYSQL_PORT}" -u"${MYSQL_USER}" "${MYSQL_DATABASE}" < "$sql_file" 2>/tmp/migration_error.log; then echo "✓ SUCCESS" SUCCESS=$((SUCCESS + 1)) else