Skip to content

Latest commit

 

History

History
124 lines (96 loc) · 9.66 KB

config.md

File metadata and controls

124 lines (96 loc) · 9.66 KB

Configuration

The serve and migrate commands read configuration once at startup. Changes require restarting serve or rerunning migrate; runtime reload is not supported. The version command does not require service configuration.

Sources and precedence

The service supports command-line flags, environment variables, and built-in defaults, in descending order of precedence. Configuration files, remote configuration, and a --config flag are not supported.

An unset or empty environment variable uses the built-in default. Each command reads an environment variable only when its flag is not given. A flag therefore also overrides a malformed variable. An environment variable uses the syntax of its flag, except SHUTDOWN_TIMEOUT (see below).

serve options

Flag Environment variable Default Meaning and validation
--server-addr HYPERFLEET_SERVER_ADDR :8000 REST v1 listen address. Must not be empty; an invalid or occupied address fails listener startup.
--health-addr HYPERFLEET_HEALTH_ADDR :8080 HTTP listen address for /healthz and /readyz. Must not be empty; an invalid or occupied address fails listener startup. Port 8080 is the platform default for probes.
--metrics-addr HYPERFLEET_METRICS_ADDR :9090 HTTP listen address for /metrics. Must not be empty; an invalid or occupied address fails listener startup. Port 9090 is the platform default for metrics. See metrics.md.
--shutdown-timeout SHUTDOWN_TIMEOUT 20s Positive duration bounding graceful shutdown, including request drain and database pool cleanup. The pod's terminationGracePeriodSeconds must be above the preStop sleep plus this value.
--log-level, -l HYPERFLEET_LOG_LEVEL info Minimum log severity: debug, info, warn, or error.
--log-format, -f HYPERFLEET_LOG_FORMAT json Log encoding: json or text.
--log-output HYPERFLEET_LOG_OUTPUT stdout Log destination: stdout or stderr.
--partition-claim HYPERFLEET_PARTITION_CLAIM none, required Wristband claim that carries the caller's partition.
--wristband-issuer HYPERFLEET_WRISTBAND_ISSUER none, required iss claim every Wristband must carry.
--wristband-audience HYPERFLEET_WRISTBAND_AUDIENCE none, required aud claim every Wristband must carry.
--wristband-jwks-url HYPERFLEET_WRISTBAND_JWKS_URL none, required Absolute https URL of the key set that signs Wristbands, without user information. http is accepted only on a loopback host, for local development and tests.
--wristband-jwks-ca-file HYPERFLEET_WRISTBAND_JWKS_CA_FILE none: the system trust store PEM CA bundle that is trusted in addition to the system trust store. If supplied, the file must be readable at startup.
--wristband-algorithms HYPERFLEET_WRISTBAND_ALGORITHMS ES256 Accepted signing algorithms, separated by commas without spaces, for example ES256,ES384. An unknown algorithm and none fail startup.
--sweeper-identity HYPERFLEET_SWEEPER_IDENTITY none, required hf_identity of the centralized sweeper, in the form system:serviceaccount:<namespace>:<name>. Every other fleet-scoped caller gets the Adapter's permissions.
--db-max-concurrency HYPERFLEET_DB_MAX_CONCURRENCY none, required Maximum PostgreSQL connections per service replica. Must be at least 2. Size it to fit your database's connection budget across all replicas. Each authenticated caller can use at most one fewer connection than this cap.
--db-acquire-timeout HYPERFLEET_DB_ACQUIRE_TIMEOUT 1s Positive duration covering admission and connection checkout.
--db-operation-timeout HYPERFLEET_DB_OPERATION_TIMEOUT 5s Positive duration covering all database operations and lock waits for one request.

The two database timeouts must total at most 25s. Authentication, validation, and database work share the first 25s of the HTTP response window; the remaining 5s are reserved for rollback and writing the response.

SHUTDOWN_TIMEOUT is intentionally unprefixed, following the graceful shutdown standard. There is no HYPERFLEET_SHUTDOWN_TIMEOUT alias.

The environment accepts both Go duration strings (20s, 1h30m) and bare integer seconds (20). The --shutdown-timeout flag accepts Go duration strings and should include a unit, for example --shutdown-timeout=30s.

During shutdown, the service reserves up to 2s (at most one third of the configured timeout) for dependency cleanup. If the drain exceeds the remaining time, the service closes active HTTP connections before closing the pool.

Malformed durations, non-positive shutdown timeouts, unsupported logging values, and missing or invalid required settings fail startup. They are not silently ignored.

PostgreSQL connection options for serve and migrate

Flag Environment variable Default Meaning and validation
--db-host HYPERFLEET_DB_HOST none, required One read-write PostgreSQL endpoint (TCP hostname or IP address) covered by the server certificate. Neither a host list nor a Unix socket is supported.
--db-port HYPERFLEET_DB_PORT 5432 PostgreSQL TCP port, from 1 to 65535.
--db-name HYPERFLEET_DB_NAME none, required Must explicitly name desire_store.
--db-username HYPERFLEET_DB_USERNAME none, required The runtime role for serve or the provisioned schema owner's login for migrate.
--db-ssl-mode HYPERFLEET_DB_SSL_MODE none, required Must be verify-full.
--db-root-cert-file HYPERFLEET_DB_ROOT_CERT_FILE none, required Readable PEM certificate authority (CA) bundle supplied by the database owner.
none HYPERFLEET_DB_PASSWORD none, required Password for the selected login; supply it through the role's secret, not a flag.

Both commands require an actual, hostname-verified Transport Layer Security (TLS) connection before starting work. PostgreSQL PG* variables and password files do not supply connection defaults; unset PGSERVICE if it is set. After replacing the CA bundle, restart serve to load it into the connection pool.

Run migrate before serve. migrate applies pending migrations under an advisory lock; rerunning the command against the same database is safe. Keep the schema owner's credential separate from the service's runtime credential. During dependency initialization, /readyz returns 503. The data plane starts only after serve opens a read-write session, verifies access to the migrated table with the runtime credential, and loads the Wristband signing keys. The pool requires each new connection to support read-write transactions. Once started, probes report process state and do not query PostgreSQL.

Database provisioning

The platform admin provisions the database before either command runs, per ADR-0026 and the co-located databases design:

  • The desire_store_migrate role that owns the desire_store schema. migrate must run as that role's login: tables created under a different owner leave the runtime role without its default privileges, and serve then fails its startup access check.
  • The desire_store_app runtime role with USAGE on the schema and SELECT, INSERT, UPDATE, DELETE on tables through ALTER DEFAULT PRIVILEGES defined for the migration role. It holds no CREATE or TEMPORARY privilege.

The schema must be pre-created and owned by the migration role: migrate does not run CREATE SCHEMA, so the design's alternative of granting CREATE and letting the role create the schema itself is not supported. The ledger's creation transaction also revokes access for the runtime role by name, so both roles must exist before migrate runs.

The executable reference for these grants is test/integration/roles.sql, which the integration suite applies to its ephemeral PostgreSQL. Deployed provisioning and Secret wiring belong to HYPERFLEET-1828.

Example

HYPERFLEET_SERVER_ADDR=:9000 SHUTDOWN_TIMEOUT=30 \
  ./bin/hyperfleet-desire-store serve --log-format=text --shutdown-timeout=25s

The example needs the required settings from the table in the environment too. It listens on :9000 for the data plane and :8080 for health checks. It logs text to stdout at info level. It uses the flag's 25s shutdown budget instead of the environment's 30 seconds.

Run migrate first, with the schema owner's login instead of the runtime role's:

HYPERFLEET_DB_PASSWORD="$MIGRATE_PASSWORD" HYPERFLEET_DB_HOST=postgres.hub.svc \
  HYPERFLEET_DB_NAME=desire_store HYPERFLEET_DB_USERNAME=desire_store_migrate \
  HYPERFLEET_DB_SSL_MODE=verify-full HYPERFLEET_DB_ROOT_CERT_FILE=/etc/hyperfleet/db-ca.pem \
  ./bin/hyperfleet-desire-store migrate

The database must be provisioned as described in Database provisioning.

References