fix provision: use direct SQL for ALTER ROLE, non-fatal image pulls
- psql -v variable interpolation doesn't work in -c mode on PostgreSQL 18. Use direct SQL string with single-quoted password (passwords are base64url, no special SQL chars). - Make image pull/retag loop non-fatal (|| true) so deploy continues even if images haven't been pushed yet for this commit. - Preserve bootstrap-tier credentials from .env (previous commit).
This commit is contained in:
@@ -278,7 +278,7 @@ steps:
|
||||
- FQDN=gitea.homelab.fhirworx.io
|
||||
- for SVC in notebooks zotero docs api mc; do
|
||||
docker pull $FQDN/homelab/$SVC:$TAG &&
|
||||
docker tag $FQDN/homelab/$SVC:$TAG fhirworx/$SVC:$TAG;
|
||||
docker tag $FQDN/homelab/$SVC:$TAG fhirworx/$SVC:$TAG || true;
|
||||
done
|
||||
# Two-phase provision + restart + health check
|
||||
- uv sync --no-dev
|
||||
|
||||
@@ -131,10 +131,8 @@ def provision_postgres(
|
||||
"psql",
|
||||
"-U",
|
||||
"postgres",
|
||||
"-v",
|
||||
f"pw={pw}",
|
||||
"-c",
|
||||
f"ALTER ROLE {role} PASSWORD :'pw'",
|
||||
f"ALTER ROLE {role} PASSWORD '{pw}'",
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
@@ -154,10 +152,8 @@ def bootstrap_postgres(values: dict[str, str], *, container: str = "postgres") -
|
||||
"psql",
|
||||
"-U",
|
||||
"postgres",
|
||||
"-v",
|
||||
f"pw={superuser_pw}",
|
||||
"-c",
|
||||
"ALTER ROLE postgres PASSWORD :'pw'",
|
||||
f"ALTER ROLE postgres PASSWORD '{superuser_pw}'",
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
@@ -184,10 +180,8 @@ def bootstrap_postgres(values: dict[str, str], *, container: str = "postgres") -
|
||||
"psql",
|
||||
"-U",
|
||||
"postgres",
|
||||
"-v",
|
||||
f"pw={pw}",
|
||||
"-c",
|
||||
f"ALTER ROLE {role} PASSWORD :'pw'",
|
||||
f"ALTER ROLE {role} PASSWORD '{pw}'",
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
|
||||
@@ -170,21 +170,9 @@ class TestProvisionPostgres:
|
||||
assert cmd[0] == "docker"
|
||||
assert cmd[1] == "exec"
|
||||
assert "test-pg" in cmd
|
||||
assert "-v" in cmd
|
||||
assert "-e" in cmd
|
||||
assert ":'pw'" in cmd[-1]
|
||||
|
||||
def test_no_password_in_sql(self):
|
||||
values = derive_all(ROOT, COMMIT)
|
||||
with patch("api.auth.provision.subprocess.run") as mock_run:
|
||||
from api.auth.provision import provision_postgres
|
||||
|
||||
provision_postgres(values, container="pg")
|
||||
|
||||
for c in mock_run.call_args_list:
|
||||
sql = c[0][0][-1]
|
||||
for env_var in POSTGRES_ROLES.values():
|
||||
assert values[env_var] not in sql
|
||||
assert "ALTER ROLE" in cmd[-1]
|
||||
assert "PASSWORD" in cmd[-1]
|
||||
|
||||
|
||||
class TestProvisionGitea:
|
||||
|
||||
Reference in New Issue
Block a user