sbarbase
Contents

Provisioning

What it is

Provisioning is the background work that turns "create environment" into a running database, logins, connection rules and services. It is written so that a crash at any moment never causes the same work to run twice on a guess; when the outcome is unknown, it stops and asks for an operator.

Why

Choice: record before acting, refuse when unsure. Creating an environment touches Docker, PostgreSQL and files. If the worker dies halfway, simply retrying could create a second database, reuse a half-made login, or overwrite connection rules another operation just wrote. So every external effect is preceded by a durable record, and after a crash the worker settles only what it can prove.

Rejected alternative: idempotent retry. "Just run it again, it is idempotent" assumes every step can detect its own partial result. Several cannot (a database created but not yet closed to other logins, a reload that was sent but not confirmed), and guessing wrong on a shared engine can hurt a neighbour.

How we built it

Five steps: queue a job, one worker claims it, it writes an effect receipt to disk, runs the fenced effect, records the outcome and consumes the receipt; after a crash a completed receipt is settled, an interruption proven to precede any change is requeued, and an unknown outcome stops for an operator

Record first, act, then settle. An unknown outcome never runs twice on a guess.

The same exchange as a sequence:

A sequence between the control API, the catalog, the worker with its exclusive lock, the receipt file and Docker with SQL: queue a job, claim it, write the receipt and flush it, run the fenced effect, get a known outcome, record it with the job completion, consume the receipt; after a crash a completed receipt is settled and an unknown one stops

The receipt is on disk before the effect runs, and consumed only after the outcome is in the catalog.

The pieces, in plain words (each term is also in the glossary):

Code: lab/worker.py, lab/effect_receipt.py, lab/effect_lease.py, lab/provision.py, lab/sql_operation_fence.py, lab/hba_authority.py, lab/hba_generation.py, lab/migrate-generation.py. The read-only inspector is lab/inspect-provisioning.py.

Limits

Go deeper

Edit on GitHub