From b8ed763062d41d11fbc0db8cbf38ff59a43ec5ee Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Feb 2026 18:31:03 +0900 Subject: [PATCH] fix: Do not generate random password on Helm upgrade Previously, when WP_ADMIN_PASSWORD was empty, the init container would generate a random password and update the Secret. However, Helm upgrades would start fresh containers and regenerate a new random password, causing the Secret to not match WordPress's actual admin password. Changes: - Remove random password generation logic - Require WP_ADMIN_PASSWORD to be explicitly set in values.yaml - Exit with error if password is not provided during installation - Only install WordPress once when database tables don't exist - During upgrades, no installation occurs so password remains unchanged This ensures: 1. Initial deployment: Admin must set WP_ADMIN_PASSWORD in values.yaml 2. Helm upgrades: No password changes occur (WordPress unchanged) 3. Helm rollbacks: Original password still works 4. Secret consistency: Secret always matches WordPress's actual password Important for users: - Initial deployment requires WP_ADMIN_PASSWORD in values.yaml - If not provided, installation will fail with clear error message - This prevents the password mismatch issue on upgrades Co-Authored-By: Claude Haiku 4.5 --- templates/deployment.yaml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 40e3475..49a99b4 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -144,15 +144,15 @@ spec: if [ -z "$TABLES" ]; then echo "=== Starting WordPress Installation ===" - + if [ -z "$WP_ADMIN_PASSWORD" ]; then - WP_ADMIN_PASSWORD=$(tr -dc 'A-Za-z0-9!@#$%^&*' < /dev/urandom | head -c 16) - echo "Generated admin password: $WP_ADMIN_PASSWORD" - echo "$WP_ADMIN_PASSWORD" > /var/www/html/wp-content/.initial-admin-password + echo "ERROR: WP_ADMIN_PASSWORD is not set. WordPress installation requires an admin password." + echo "Skipping WordPress installation. Please set WP_ADMIN_PASSWORD in values.yaml" + exit 1 fi - + INSTALL_URL="http://127.0.0.1" - + echo "Installing WordPress..." /tmp/wp-cli.phar --path=/var/www/html core install \ --url="$INSTALL_URL" \ @@ -161,12 +161,10 @@ spec: --admin_password="$WP_ADMIN_PASSWORD" \ --admin_email="$WP_ADMIN_EMAIL" \ --skip-email - + echo "=== WordPress Installation Completed ===" echo "Admin User: $WP_ADMIN_USER" - if [ -f /var/www/html/wp-content/.initial-admin-password ]; then - echo "Admin Password: $(cat /var/www/html/wp-content/.initial-admin-password)" - fi + echo "Admin password was set from values.yaml" else echo "WordPress is already installed, skipping installation" if [ -f /tmp/wp-cli.phar ]; then