Procedures¶
Intended audience: Anyone who is administering the Prompt Publication Service.
Deployment¶
Deployed via Phalanx. Scheduled scale up and down daily via CronJobs.
Maintenance¶
Backup¶
Cold Startup¶
Set up prompt repo¶
Enable the AlloyDB cluster via Terraform by setting
butler_prompt_data_products_enabled = trueinidf_deploy/environment/deployments/science-platform/env/<env>-cloudsql.tfvars. Open a Pull Request and ensure the Terraform Plan of the GitHub Actions is correct. Merging tomainauto-applies via the corresponding GitHub Actions workflow and creates:AlloyDB cluster
butler-prompt-<env>Primary instance
butler-prompt-<env>-primary(public IP enabled)Read pool instance
butler-prompt-<env>-readpool(private IP only)Private DNS record
alloydb-butler-prompt.rsp-sql-<env>.internalpointing at the read pool IPService account
usdf-alloydb-auth-proxywithroles/alloydb.client
Obtain postgres admin access, via GCP console or via
gcloudcommands.Create the database
promptand required extensionbtree_gist. One way to do it is via AlloyDB Studio. In AlloyDB Studio, connect aspostgresand run:CREATE DATABASE prompt;
Switch the database
prompt, then:CREATE EXTENSION btree_gist;
Create postgres user
prompt_puband grant it privileges to thepromptdatabase.Verify connection from SLAC via the AlloyDB Auth Proxy. Generate a key for the
usdf-alloydb-auth-proxyservice account, then:alloydb-auth-proxy \ --credentials-file=<key.json> --public-ip \ --address=127.0.0.1 --port=5432 \ "projects/<project-id>/locations/us-central1/clusters/butler-prompt-<env>/instances/butler-prompt-<env>-primary"
A key can be found at SLAC’s vault:
vault kv get secret/rubin/<vCluster-name>/prompt-pub
Then one way to test the connection is
psql "host=127.0.0.1 port=5432 user=prompt_pub dbname=prompt".Obtain a template prompt butler config yaml from phalanx
applications/butler/templates/configmap-private.yaml, at RSP supply a temporary~/.lsst/db-auth.yamllocally, and create a butler repo bybutler create repo --seed-config prompt.yamlwhere a direct IP, not the read pool, to the postgres is given.Run
lsst.prompt_publication_service.scripts.initialize_google_repoto finish initializing the butler repo fromprompt_preptoprompt. Creation of temporary tables in the database is needed.
Set up state database¶
The Prompt Publication Service’s state database is a separate Postgres database at USDF. Its schema can created via Alembic migration.
Confirm the empty database is reachable directly:
psql "postgresql://<user>:<password>@<host>:<port>/<dbname>" -c "\dt"
An empty result confirms no tables exist yet.
Check out prompt_publication_service on
main.Run the Alembic migration from the repository root (where
alembic.inilives), passing the state database URL via-x database_url=:PYTHONPATH=python uv run alembic -x database_url="postgresql+asyncpg://<user>:<password>@<host>:<port>/<dbname>" upgrade head
Verify the migration applied, either via Alembic:
PYTHONPATH=python uv run alembic -x database_url="postgresql+asyncpg://<user>:<password>@<host>:<port>/<dbname>" current
which should report
b59eced2ad76 (head), or directly in Postgres:psql "postgresql://<user>:<password>@<host>:<port>/<dbname>" -c "SELECT * FROM alembic_version;"
which should return one row with
version_numofb59eced2ad76.\dtshould no longer be empty.