feat(selfhost): configure-rds.sh is the guided, primary EKS + RDS install path

Merged
KH
7d ago
+544-79

Stacked on #554 (helm test status). GitHub retargets it to main once #554 merges. Part D of the series after #552 (databaseGuard, merged).

Why configure-rds.sh, not a new install.sh

configure-rds.sh already owns the hard part end to end: the master-login handling, rds-setup.sh pre/post with the HoopDb layout overlay, the release pins, helm, the migration wait and first sign-in. Customers and support already know it by name. A new entry point would only wrap or duplicate it. So it now covers the whole install, and hand-filled Secrets 01โ€“05 become the bring-your-own option, which databaseGuard checks.

What changed

  • Secrets: it generates the application keys (step 10 of the install guide) only when neither the cluster nor the credential files have them, and never replaces an existing key. Losing selfhost-encryption-key or SUMMARY_MASTER_KEYS loses data. It copies the ingest introspect-secret, writes the five Secrets in the shapes the guard checks, and tells you what to back up.
  • CA pin: it pins the rds-ca sha256 into every caSha256/sha256 64-hex value in values.yaml. If the chart computes the CA hash itself (the chart-owned CA work), there is nothing to replace and this does nothing.
  • helm: it runs helm with databaseGuard.statusTest.rbac.create=true (STATUS_RBAC=0 to opt out). If helm refuses, the script points at the AR_DB_LOGIN message and the db-guard hook log, then stops.
  • Search bootstrap (coordinator addendum): after rds-setup.sh post, a search bootstrap Job that hasn't succeeded is deleted and re-run through helm. The wait stops on Complete or Failed and prints the Job's last lines. In the rehearsal, the failed Job kept its name, helm never re-ran it, and the indexer crash-looped on permission denied for schema sessions.
  • First sign-in (addendum): it waits for the relay-control rollout, then retries the port-forward and the request up to 6 times. The rehearsal failed here with curl: (7) Failed to connect to 127.0.0.1:18787.
  • Verdict (addendum): the script ends with helm test and then the support diagnostic, followed by one plain line (HEALTHY, UNHEALTHY or INCOMPLETE) and numbered Next: steps.
  • diagnose-install.py (addendum): the cluster probe retries 3 times (8s, 15s, 30s) before giving up. Skipped workload checks now end in RESULT: INCOMPLETE: workload checks skipped ... with exit 3, never a clean-looking summary. It also prints RESULT: FAIL, PARTIAL or PASS. The installer prefers the diagnostic next to it in the checkout over the older pinned download.
  • RELEASE_VERSION=checkout: uses this checkout's chart, rds-setup.sh and diagnostic as they are, for unreleased charts and tests.
  • Docs: scripts/selfhost/README.md leads with the installer. examples/aws/README.md and the Secret 01โ€“05 comments describe hand-written Secrets as bring-your-own, subject to the guard. docs/self-hosted-rds-manual-setup.md and docs/self-hosted-eks.md point to the installer first. Registry: opt.agent-relay.database-guard, docs regenerated with check passing.

Later commits (coordinator addenda from the live rehearsal)

  • Hidden overlay: the HoopDb layout (worker.migrations.hoopdb, rdsLayout, searchIndexer.bootstrap), relay-control.bootstrap.adminEmail and databaseGuard.statusTest.rbac.create used to be passed as an extra -f $STATE_DIR/hoopdb-layout-values.yaml plus --set flags. They are now written into the operator's values file (a .bak is kept), so a later plain helm upgrade with the documented -f files keeps them. In the rehearsal, dropping them made the migrate Job fail with rds_profile_unproven at revision 4. The writer edits block YAML in place and never touches comments, anchors or flow mappings. If it can't edit the file, the script falls back to the overlay with a loud warning. The chart guard in #554 also refuses an unset rdsLayout that comes with a dedicated HoopDb owner.
  • --reset-databases on a dedicated-owner install: this used to drop relaycontrol and relaycast and then fail with must be owner of database hoopdb. The reset now checks ownership first and refuses with "Nothing was dropped" (verified: refused in 5 seconds).
  • Job waits: a new wait_job returns as soon as a Job is Complete or Failed. It covers the reset, migration and search bootstrap waits; kubectl wait --for=condition=complete sat out its full timeout (300s or 1200s) on a Job that had already failed. The fresh e2e now takes 766 seconds, down from more than 25 minutes.
  • Search bootstrap cause: before the installer deletes a failed search bootstrap Job, it prints the Job's recorded cause (the guard's termination message, see #554).

Tests

scripts/selfhost/tests/configure-rds-e2e runs on kind with an RDS-shaped PG17 over TLS and replays the rehearsal's exact Secrets (every URL logs in as postgres, and 04 holds a bare URL).

  • 02: helm install is now refused before anything is applied:
    AR_DB_LOGIN: the database credentials in this release's Secrets are wrong; nothing was installed or changed:
      - agent-relay-secrets: database-url logs in as "postgres" (the RDS master user). Each service needs its own login.
      ... (8 more)
      - search-indexer-runtime: RELAYHISTORY_PIPELINE_CONSUMER_SECRET holds a bare URL; it must be JSON {"hoopdb_url":"postgresql://..."}.
    
  • 03: this checkout's installer with --reset-databases. The logins were created and the keys generated. The CA was pinned (4 values). The guard hook passed, and all three migrate Jobs completed. post reported login ok โ€ฆ tls=true for the read API, ingest and search logins. The early search bootstrap was deleted and re-run, helm test printed the table, and the first sign-in key was minted.
  • Final fresh run (766s): 04 passes on: the plain verdict and Next lines, a plain helm upgrade (documented -f files only) keeps rdsLayout (separate-database), the generated keys, the minted setup key, and the credential checks. The rows that need S3 or OpenSearch fail, as described below.
  • 04 (first run): PASS on the credential checks, the generated keys, the status table and the minted setup key. The harness has no S3 or OpenSearch, so the S3-backed pods crash, and the search bootstrap fails on OpenSearch ENOTFOUND. That means the search runtime never gets its sessions grant. The status table and the diagnostic both report exactly that, and those 04 rows fail. A fully HEALTHY end to end needs real or faked S3 and OpenSearch: not verified here.
  • scripts/support/tests: 26/26, including the new retry and INCOMPLETE tests.
  • Also: shellcheck -S warning and the registry check pass.

๐Ÿค– Generated with Claude Code


Open in [code]smith ยท Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Makes configure-rds.sh the guided, primary install path for EKS + RDS. It creates the database logins, writes the install Secrets, pins the CA and image digests, runs helm with the status-test RBAC, reruns a failed search bootstrap, and ends with helm test plus one verdict line. Hand-writing Secrets 01โ€“05 is now the bring-your-own option, refused by the chart when a URL logs in as the RDS master, shares a login between roles, or has the wrong shape.

Installer

  • Generates application keys only when neither the cluster Secret nor the credential files hold one; existing keys are never replaced, and it names what to back up.
  • Pins the rds-ca sha256 into every 64-hex caSha256/sha256 in values.yaml.
  • Writes the HoopDb layout, first admin email and status-test RBAC settings into values.yaml so a later plain helm upgrade keeps them; falls back to an overlay with a loud warning when the YAML shape isn't editable.
  • Prints a failed search bootstrap Job's cause, then deletes and re-runs it (it ran before rds-setup.sh post activated the search logins).
  • Refuses --reset-databases when the master can't act as owner of all three databases: nothing is dropped.
  • Stops at the first Complete or Failed Job instead of waiting out the timeout.
  • Waits for relay-control's rollout and retries first sign-in up to 6 times.
  • Supports RELEASE_VERSION=checkout to run this checkout's chart and scripts instead of pinned releases.

Diagnostic

  • diagnose-install.py retries the cluster probe 3 times (8s, 15s, 30s) and always ends with RESULT: FAIL, PARTIAL, PASS, or INCOMPLETE; skipped workload checks exit 3, never a clean-looking summary.
  • The installer uses the diagnostic next to it in the checkout and finishes with one verdict line and numbered Next: steps.
  • Docs lead with the installer and describe hand-written Secrets as bring-your-own; opt.agent-relay.database-guard was added to the requirements registry.