Skip to content

fix: reconcile the assistant->agents postgres rename on existing volumes#659

Merged
ExtraToast merged 1 commit into
mainfrom
fix/agents-db-rename-reconcile
Jun 11, 2026
Merged

fix: reconcile the assistant->agents postgres rename on existing volumes#659
ExtraToast merged 1 commit into
mainfrom
fix/agents-db-rename-reconcile

Conversation

@ExtraToast

Copy link
Copy Markdown
Owner

Problem

The assistant subsystem was renamed to agents (#657). init-databases.sh
was updated to create agents_db / agents_user, and the postgres
deployment template now sources agents.user / agents.password from
secret/platform/postgres. Two pieces of live state did not follow:

  • secret/platform/postgres still held assistant.user / assistant.password
    and no agents.* keys, so AGENTS_DB_PASSWORD rendered empty and the
    . /vault/secrets/postgres.env source failed with syntax error: unexpected newline. Postgres crash-looped, which cascaded into auth-api, knowledge-api
    and n8n (all Connection refused to postgres:5432).
  • init-databases.sh only runs on a fresh PGDATA, so the Frankfurt volume
    still carried assistant_db / assistant_user. Even with postgres healthy,
    agents-api could not reach jdbc:postgresql://.../agents_db.

The Vault KV keys were added out-of-band. This PR closes the database half.

Change

A one-shot reconcile Job (modelled on postgres-wolfmanager-reconcile)
renames assistant_user -> agents_user and assistant_db -> agents_db
in place, preserving all data and the Flyway history. It resets the role
password from secret/platform/postgres (covering the md5 RENAME edge case)
and falls back to creating the objects when neither name exists, so a fresh
cluster where the init script already created agents_db is a no-op. Re-runs
are idempotent.

Verification

  • Applied to the live Frankfurt postgres: ALTER ROLE + ALTER DATABASE
    succeeded; agents-api's vault-agent-init now authenticates and renders.
  • postgres, auth-api, knowledge-api and n8n returned to Ready.
  • node --test in platform/tests: 55/55 pass.
  • kubectl kustomize platform/cluster/flux/clusters/production builds clean.

The agents subsystem rename left the init script creating agents_db /
agents_user, but init-databases.sh only runs on a fresh PGDATA. On the
live Frankfurt volume the database and role were still named assistant_db
and assistant_user, so agents-api could not reach jdbc:.../agents_db and
postgres itself crash-looped once secret/platform/postgres gained the
agents.* keys the deployment template now references.

A one-shot reconcile Job renames the role and database in place,
preserving all data, resets the role password from secret/platform/postgres,
and falls back to creating the objects when neither name exists (fresh
cluster). It is idempotent: a second run is a no-op.
@ExtraToast ExtraToast added the bug Something isn't working label Jun 11, 2026
@ExtraToast ExtraToast self-assigned this Jun 11, 2026
@ExtraToast ExtraToast merged commit 4f0dc7c into main Jun 11, 2026
24 checks passed
@ExtraToast ExtraToast deleted the fix/agents-db-rename-reconcile branch June 11, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant