Skip to content

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

Merged
khaliqgant merged 1 commit into
feat/selfhost-helm-test-statusfrom
feat/selfhost-guided-install
Nov 27, 2026
Merged

khaliqgant merged 1 commit into
feat/selfhost-helm-test-statusfrom
feat/selfhost-guided-install

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

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 feat(agent-relay): helm test install status, search bootstrap causes, guided configure-rds.sh (agent-relay 0.7.87, sessions-pipeline 0.8.62) #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 feat(agent-relay): helm test install status, search bootstrap causes, guided configure-rds.sh (agent-relay 0.7.87, sessions-pipeline 0.8.62) #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.

Written for commit e5cdb39. Summary will update on new commits.

View guided diff Turn on auto-fix

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 418f851e-b6ea-4c57-8c03-bec2f1514b54

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 4 potential issues.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment on lines +84 to +86
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
CHECKOUT=0; [[ "$RELEASE_VERSION" == checkout ]] && CHECKOUT=1
STATUS_RBAC="${STATUS_RBAC:-1}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Default release blocks checkout installs

The guided install command passes the checkout chart, but RELEASE_VERSION defaults to an older release and rejects it. Switching to the pinned chart avoids the rejection but leaves helm test without the advertised status hook.

Learn more

The guided install command uses a local chart path without setting RELEASE_VERSION. The installer defaults to release 2026.11.18 and compares the chart version with that release’s chart before provisioning. That release ships chart 0.7.63 without the database guard or status test; the current checkout chart is 0.7.85 and includes them.

Example: Use the quickstart against the current checkout. The script rejects 0.7.85 because it expects 0.7.63. Point it at 0.7.63 instead, and the status stage cannot print the new table even when the installation succeeds.

Recommended fix: Make the checkout quickstart explicitly select RELEASE_VERSION=checkout. For the pinned path, select a release that ships the required hooks or explicitly handle and document the older release’s lack of status support. Test the documented invocation as well as the checkout override.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +409 to +413
failed_boot="$(k get jobs -o json | jq -r '.items[] | select(.metadata.name | test("search-indexer-bootstrap")) | select((.status.succeeded // 0) == 0) | .metadata.name')"
if [[ -n "$failed_boot" && -n "${HELM_CHART:-}" ]]; then
for j in $failed_boot; do k delete job "$j" >/dev/null && info "deleted $j to rerun it"; done
helm_upgrade >/dev/null || die "helm upgrade (search bootstrap rerun) failed"
boot="$(k get jobs -o name | grep search-indexer-bootstrap | head -n1)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Search repair deletes other releases’ jobs

With another search release in the namespace, failed_boot includes its running or failed bootstrap jobs. The installer deletes them but upgrades only the selected release, leaving the other release’s jobs missing.

Learn more

The search bootstrap Job template labels the Job with both its Helm release and its bootstrap component. It also includes a hash in the Job name so changed inputs create a different Job. The installer does not use either label when deleting a Job, and it chooses the first matching name in the namespace when waiting for the rerun. The Helm upgrade manages only the selected release.

Example: Run the installer for agent-relay in a namespace where analytics-search-indexer-bootstrap-1234abcd is still running. The installer deletes the analytics Job and upgrades agent-relay; the analytics Job is not recreated.

Recommended fix: Identify the selected release’s current bootstrap Job using the release manifest or both release and component labels. Confirm its terminal failure before deleting it, and wait for that exact Job after the upgrade. Leave active and unrelated Jobs untouched.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +277 to +279
for key in "${APP_KEYS[@]}"; do
f="$FILES/agent-relay-secrets/$key"
if secret_has agent-relay-secrets "$key"; then rm -f "$f"; continue; fi # keep the cluster's value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Reruns erase saved encryption keys

On a routine rerun, secret_has triggers deletion of the local encryption keys when they also exist in Kubernetes. After losing the cluster Secret, an operator cannot recover those keys from the installer’s credential directory.

Learn more

The installer writes selfhost-encryption-key and SUMMARY_MASTER_KEYS to the private credential directory and tells the operator to back up those files. A second run preserves the deployed keys by removing them from the local directory before building the Secret patch. That removes the recovery copies even though the cluster values did not change.

Example: Complete an install, ingest data, and run the recommended retry. The Kubernetes Secret still contains the original keys, but their saved files are gone. Restoring the database without the Kubernetes Secret or an independent backup then leaves encrypted data unreadable.

Recommended fix: Keep the key files separate from the patch inputs. Omit application keys already present in Kubernetes when building the patch rather than deleting their files. If local files are meant to mirror the deployed values, update them privately and atomically from the authoritative Secret.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +467 to +476
k rollout status "deployment/$SVC" --timeout=600s >/dev/null 2>&1 || info "relay-control is not rolled out yet; trying anyway"
for attempt in 1 2 3 4 5 6; do
k port-forward "svc/$SVC" 18787:"$PORT" >/dev/null 2>&1 & PF=$!
for _ in $(seq 1 20); do
curl -s -o /dev/null --max-time 2 http://127.0.0.1:18787/ 2>/dev/null && break
kill -0 "$PF" 2>/dev/null || break
sleep 1
done
code="$(curl -sS -o "$WORK/setup-key.json" -w '%{http_code}' -X POST -H "Authorization: Bearer $TOKEN" \
http://127.0.0.1:18787/api/v1/installation/setup-key 2>/dev/null || true)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟥 Bootstrap token sent to unverified listener

The first sign-in retry trusts any HTTP response on port 18787 without confirming that kubectl port-forward owns it. A local user on a shared installer host can receive the bootstrap token, even when the deployment never became ready.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Confidence Score: 0/5 · Do not merge yet: reruns can lose saved encryption keys or replace live ones, and the installer can delete another release's bootstrap Jobs.RetriggerView in GreptileConfidence Score: 0/5

[Critical impact] The PR changes the operator-run EKS and RDS install path, including writes to Kubernetes Secrets and database setup.

Do not merge yet: reruns can lose saved encryption keys or replace live ones, and the installer can delete another release's bootstrap Jobs.

FindingsFix All in CodexFindings

  1. P1 Reruns delete saved encryption keys ▶
  2. P1 Failed reads can replace keys ▶
  3. P1 Healthy installs end as incomplete ▶
  4. P1 Cleanup deletes other releases' Jobs ▶
  5. P1 Quoted settings get replaced ▶
  6. P1 Enrollment keys stop working ▶
  7. P2 Existing keys bypass generation coverage ▶
  8. P2 Finished bootstrap looks unfinished ▶
Fix with agent prompt
### Issue 1
scripts/selfhost/configure-rds.sh:undefined-337
A normal rerun deletes the saved application keys whenever they already exist in Kubernetes. This includes `selfhost-encryption-key` and `SUMMARY_MASTER_KEYS`, which the first run tells the operator to back up. Losing the Kubernetes Secret afterward would leave no local recovery copy. Keep these files; if the cluster holds a different value, save that value privately before proceeding.

### Issue 2
scripts/selfhost/configure-rds.sh:330-332
`secret_has` treats a failed Kubernetes read as a missing key. If a read times out and the local key file is absent, the loop generates a replacement. When the later patch succeeds, it overwrites the existing cluster key. For the encryption keys, this makes existing data unreadable. Require a successful Secret read before generating anything, and distinguish a missing key from a failed request.

### Issue 3
scripts/selfhost/configure-rds.sh:645-649
With the diagnostic beside this script, even a healthy install ends as `INCOMPLETE`. The installer passes `--scope cluster`, which always adds a database `UNKNOWN` because database checks were not requested. The diagnostic therefore returns `2`, and `HEALTHY:2` falls through to “the status test did not report” despite a healthy table. Exclude deliberately unrequested checks from the unknown count, or handle this result explicitly.

### Issue 4
scripts/selfhost/configure-rds.sh:409-411
If another release has a running or failed search bootstrap in this namespace, this cleanup deletes it too. It matches every unfinished Job whose name contains `search-indexer-bootstrap`, while `helm_upgrade` only recreates resources for `$RELEASE`. The other release is left without its bootstrap Job. Filter by the release and component labels, and use that same filtered set when choosing the Job to wait for.

### Issue 5
scripts/selfhost/configure-rds.sh:undefined-415
If `values.yaml` uses a quoted top-level key such as `"sessions-pipeline":`, `KEY` does not recognize it. The editor appends another `sessions-pipeline` block containing only the new settings and reports success. Helm then reads that later block instead of the customer's original block, losing database, storage and service settings.

Use a YAML-aware edit, or reject quoted keys and use the existing overlay fallback.

### Issue 6
scripts/selfhost/configure-rds.sh:undefined-380
The CA rewrite changes every block-style `sha256` or `caSha256` value, not just RDS CA pins. If an EKS install defines `relaygate.policy.enrollmentKeys` as block mappings, each enrollment key's `sha256` gets replaced with the public RDS CA hash. Existing clients can no longer enroll with their keys.

Limit the rewrite to database CA settings that reference `rds-ca`.

### Issue 7
scripts/selfhost/tests/configure-rds-e2e/04-verify.sh:undefined-44
This assertion does not test key generation. `02-customer-state.sh` applies example Secrets containing every application key, and this check only verifies that `selfhost-encryption-key` exists afterward. It would pass if the entire generation block were removed. Add a fresh-install case with missing application keys, then assert that they are generated and remain unchanged on a second run.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 8
scripts/selfhost/configure-rds.sh:undefined-123
When the search bootstrap is rerun, `kubectl get jobs -o name` returns `job.batch/<name>`. `wait_job` strips only `job/`, then calls `kubectl get job job.batch/<name>`, which rejects the mixed argument forms. Each poll fails silently, so the installer waits ten minutes and says the bootstrap did not complete even when it succeeded.

Strip everything before the slash, or pass the full resource name without a separate `job` argument.

```suggestion
  local job="${1##*/}" deadline=$((SECONDS + $2)) state
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Makes configure-rds.sh the guided EKS + RDS install path.

  • The installer prepares Secrets and keeps its Helm settings for later upgrades.
  • The installer catches failed Jobs quickly and retries search setup and first sign-in.
  • The diagnostic retries slow cluster checks and marks skipped workloads incomplete.
  • Install guides now lead with configure-rds.sh and explain the manual Secret route.

No additional findings were accepted.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Operator values and RDS master login] --> B[Run database setup pre]
  B --> C[Generate missing keys and write Secrets]
  C --> D[Save CA pins and layout settings]
  D --> E[Helm install or upgrade]
  E --> F[Wait for HoopDb migration]
  F --> G[Run database setup post]
  G --> H[Restart services and retry search bootstrap]
  H --> I[Helm test and support diagnostic]
  I --> J[First sign-in and final result]
Loading

Reviews (7) · Last reviewed commit: "feat(selfhost): configure-rds.sh is the ..." · Reviewed by Greptile

generated=0
for key in "${APP_KEYS[@]}"; do
f="$FILES/agent-relay-secrets/$key"
if secret_has agent-relay-secrets "$key"; then rm -f "$f"; continue; fi # keep the cluster's value

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Reruns delete saved encryption keys

A normal rerun deletes the saved application keys whenever they already exist in Kubernetes. This includes selfhost-encryption-key and SUMMARY_MASTER_KEYS, which the first run tells the operator to back up. Losing the Kubernetes Secret afterward would leave no local recovery copy. Keep these files; if the cluster holds a different value, save that value privately before proceeding.

Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/selfhost/configure-rds.sh
Line: 279

Comment:
**Reruns delete saved encryption keys**

A normal rerun deletes the saved application keys whenever they already exist in Kubernetes. This includes `selfhost-encryption-key` and `SUMMARY_MASTER_KEYS`, which the first run tells the operator to back up. Losing the Kubernetes Secret afterward would leave no local recovery copy. Keep these files; if the cluster holds a different value, save that value privately before proceeding.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex Fix in Claude Code

Comment on lines +272 to +274
secret_has() { # secret key
[[ -n "$(k get secret "$1" -o jsonpath="{.data.${2//./\\.}}" 2>/dev/null)" ]]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Failed reads can replace keys

secret_has treats a failed Kubernetes read as a missing key. If a read times out and the local key file is absent, the loop generates a replacement. When the later patch succeeds, it overwrites the existing cluster key. For the encryption keys, this makes existing data unreadable. Require a successful Secret read before generating anything, and distinguish a missing key from a failed request.

Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/selfhost/configure-rds.sh
Line: 272-274

Comment:
**Failed reads can replace keys**

`secret_has` treats a failed Kubernetes read as a missing key. If a read times out and the local key file is absent, the loop generates a replacement. When the later patch succeeds, it overwrites the existing cluster key. For the encryption keys, this makes existing data unreadable. Require a successful Secret read before generating anything, and distinguish a missing key from a failed request.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex Fix in Claude Code

Comment on lines +503 to +507
case "$STATUS_VERDICT:${DIAG_RC:-none}" in
HEALTHY:0|HEALTHY:none) info "HEALTHY: every install check passed." ;;
HEALTHY:3|*:3) info "INCOMPLETE: the support diagnostic could not reach the cluster, so its workload checks were skipped." ;;
UNHEALTHY:*) info "UNHEALTHY: the status table above lists each FAIL with its fix." ;;
*) info "INCOMPLETE: the status test did not report (see above)." ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Healthy installs end as incomplete

With the diagnostic beside this script, even a healthy install ends as INCOMPLETE. The installer passes --scope cluster, which always adds a database UNKNOWN because database checks were not requested. The diagnostic therefore returns 2, and HEALTHY:2 falls through to “the status test did not report” despite a healthy table. Exclude deliberately unrequested checks from the unknown count, or handle this result explicitly.

Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/selfhost/configure-rds.sh
Line: 503-507

Comment:
**Healthy installs end as incomplete**

With the diagnostic beside this script, even a healthy install ends as `INCOMPLETE`. The installer passes `--scope cluster`, which always adds a database `UNKNOWN` because database checks were not requested. The diagnostic therefore returns `2`, and `HEALTHY:2` falls through to “the status test did not report” despite a healthy table. Exclude deliberately unrequested checks from the unknown count, or handle this result explicitly.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex Fix in Claude Code

Comment thread scripts/selfhost/configure-rds.sh Outdated
Comment on lines +409 to +411
failed_boot="$(k get jobs -o json | jq -r '.items[] | select(.metadata.name | test("search-indexer-bootstrap")) | select((.status.succeeded // 0) == 0) | .metadata.name')"
if [[ -n "$failed_boot" && -n "${HELM_CHART:-}" ]]; then
for j in $failed_boot; do k delete job "$j" >/dev/null && info "deleted $j to rerun it"; done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Cleanup deletes other releases' Jobs

If another release has a running or failed search bootstrap in this namespace, this cleanup deletes it too. It matches every unfinished Job whose name contains search-indexer-bootstrap, while helm_upgrade only recreates resources for $RELEASE. The other release is left without its bootstrap Job. Filter by the release and component labels, and use that same filtered set when choosing the Job to wait for.

Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/selfhost/configure-rds.sh
Line: 409-411

Comment:
**Cleanup deletes other releases' Jobs**

If another release has a running or failed search bootstrap in this namespace, this cleanup deletes it too. It matches every unfinished Job whose name contains `search-indexer-bootstrap`, while `helm_upgrade` only recreates resources for `$RELEASE`. The other release is left without its bootstrap Job. Filter by the release and component labels, and use that same filtered set when choosing the Job to wait for.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex Fix in Claude Code

check "helm test: every database login ok" '! grep -E "^ database " configure-rds.log | grep -qv " ok "'
check "helm test: every migration Job ok" '! grep -E "^ migrations " configure-rds.log | grep -qv " ok "'
check "a plain verdict and Next steps end the run" 'grep -qE "^ (HEALTHY|UNHEALTHY|INCOMPLETE): " configure-rds.log && grep -q "^ Next:" configure-rds.log'
check "the guide generated the application keys" 'k get secret agent-relay-secrets -o jsonpath="{.data.selfhost-encryption-key}" | grep -q .'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Existing keys bypass generation coverage

This assertion does not test key generation. 02-customer-state.sh applies example Secrets containing every application key, and this check only verifies that selfhost-encryption-key exists afterward. It would pass if the entire generation block were removed. Add a fresh-install case with missing application keys, then assert that they are generated and remain unchanged on a second run.

Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/selfhost/tests/configure-rds-e2e/04-verify.sh
Line: 40

Comment:
**Existing keys bypass generation coverage**

This assertion does not test key generation. `02-customer-state.sh` applies example Secrets containing every application key, and this check only verifies that `selfhost-encryption-key` exists afterward. It would pass if the entire generation block were removed. Add a fresh-install case with missing application keys, then assert that they are generated and remain unchanged on a second run.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex Fix in Claude Code

# the time is up. (kubectl wait --for=condition=complete keeps waiting on a
# failed Job until its timeout, then says only "timed out waiting for the condition".)
wait_job() {
local job="${1#job/}" deadline=$((SECONDS + $2)) state

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Finished bootstrap looks unfinished

When the search bootstrap is rerun, kubectl get jobs -o name returns job.batch/<name>. wait_job strips only job/, then calls kubectl get job job.batch/<name>, which rejects the mixed argument forms. Each poll fails silently, so the installer waits ten minutes and says the bootstrap did not complete even when it succeeded.

Strip everything before the slash, or pass the full resource name without a separate job argument.

Suggested change
local job="${1#job/}" deadline=$((SECONDS + $2)) state
local job="${1##*/}" deadline=$((SECONDS + $2)) state
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/selfhost/configure-rds.sh
Line: 113

Comment:
**Finished bootstrap looks unfinished**

When the search bootstrap is rerun, `kubectl get jobs -o name` returns `job.batch/<name>`. `wait_job` strips only `job/`, then calls `kubectl get job job.batch/<name>`, which rejects the mixed argument forms. Each poll fails silently, so the installer waits ten minutes and says the bootstrap did not complete even when it succeeded.

Strip everything before the slash, or pass the full resource name without a separate `job` argument.

```suggestion
  local job="${1##*/}" deadline=$((SECONDS + $2)) state
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex Fix in Claude Code

import json, os, re, sys
path = sys.argv[1]
lines = open(path).read().split("\n")
KEY = lambda k: re.compile(r"^(\s*)" + re.escape(k) + r"\s*:(\s|$)")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Quoted settings get replaced

If values.yaml uses a quoted top-level key such as "sessions-pipeline":, KEY does not recognize it. The editor appends another sessions-pipeline block containing only the new settings and reports success. Helm then reads that later block instead of the customer's original block, losing database, storage and service settings.

Use a YAML-aware edit, or reject quoted keys and use the existing overlay fallback.

Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/selfhost/configure-rds.sh
Line: 371

Comment:
**Quoted settings get replaced**

If `values.yaml` uses a quoted top-level key such as `"sessions-pipeline":`, `KEY` does not recognize it. The editor appends another `sessions-pipeline` block containing only the new settings and reports success. Helm then reads that later block instead of the customer's original block, losing database, storage and service settings.

Use a YAML-aware edit, or reject quoted keys and use the existing overlay fallback.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex Fix in Claude Code

import os, re, sys
p = sys.argv[1]; sha = os.environ["CA_SHA"]
s = open(p).read()
s, n = re.subn(r'^(\s*(?:caSha256|sha256):\s*"?)[0-9a-f]{64}("?)', lambda m: m.group(1) + sha + m.group(2), s, flags=re.M)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Enrollment keys stop working

The CA rewrite changes every block-style sha256 or caSha256 value, not just RDS CA pins. If an EKS install defines relaygate.policy.enrollmentKeys as block mappings, each enrollment key's sha256 gets replaced with the public RDS CA hash. Existing clients can no longer enroll with their keys.

Limit the rewrite to database CA settings that reference rds-ca.

Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/selfhost/configure-rds.sh
Line: 336

Comment:
**Enrollment keys stop working**

The CA rewrite changes every block-style `sha256` or `caSha256` value, not just RDS CA pins. If an EKS install defines `relaygate.policy.enrollmentKeys` as block mappings, each enrollment key's `sha256` gets replaced with the public RDS CA hash. Existing clients can no longer enroll with their keys.

Limit the rewrite to database CA settings that reference `rds-ca`.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex Fix in Claude Code

@khaliqgant
khaliqgant force-pushed the feat/selfhost-guided-install branch 2 times, most recently from 7a7e88d to 68dc817 Compare November 26, 2026 23:24
@khaliqgant
khaliqgant force-pushed the feat/selfhost-helm-test-status branch from d65e54f to a7c9eb4 Compare November 26, 2026 23:49
…tall path

Rebuilt on main after #555/#557/#558/#559 (OCI chart install, find_cluster,
in-cluster database checks). Earlier review rounds on #556 are folded in.

Why configure-rds.sh and not a new install.sh: it already owns the master
login, rds-setup.sh pre/post with the HoopDb layout, the release pins, the
chart (now the published OCI chart, #557), helm, the migration wait and
first sign-in. It now does the rest of the install too, so hand-filling
Secrets 01-05 is the bring-your-own option, and databaseGuard checks it.

- Secrets: the application keys are generated only when neither the cluster
  nor the credential files hold them, and never replaced (an empty openssl
  result stops the run). The ingest introspect-secret is copied, the five
  Secrets are written in the shapes the guard checks, and the script says
  what to back up.
- values.yaml: the rds-ca sha256 is pinned. The HoopDb layout
  (worker.migrations.hoopdb, rdsLayout, searchIndexer.bootstrap),
  relay-control.bootstrap.adminEmail and databaseGuard.statusTest.rbac.create
  are written into the operator's values file instead of a hidden -f overlay
  and --set flags, so a later plain helm upgrade keeps them (the rehearsal's
  rds_profile_unproven at revision 4). Block YAML is edited in place;
  comments, anchors and flow mappings are untouched. If the file can't be
  edited, the script falls back to the overlay with a loud warning.
- helm: works with the OCI chart and a checkout. On refusal the script
  points at AR_DB_LOGIN and the db-guard hook log, then stops.
- Jobs: wait_job returns at Complete or Failed (reset, migration, search
  bootstrap), instead of sitting out kubectl wait's timeout on a failed Job.
  A search bootstrap that failed before rds-setup.sh post is shown with its
  cause, deleted, and re-run through helm.
- --reset-databases checks that the master owns all three databases before
  dropping any. On a dedicated-owner install it refuses with "Nothing was
  dropped"; it used to drop two databases and then fail.
- Step 8: helm test, then the diagnostic next to the script when there is
  one. The run ends with one line (HEALTHY, UNHEALTHY or INCOMPLETE) and
  numbered Next steps. First sign-in waits for the relay-control rollout
  and retries the port-forward.
- diagnose-install.py: find_cluster() retries the probe (8s, 15s, 30s).
  Skipped workload checks end in "RESULT: INCOMPLETE: workload checks
  skipped" (exit 3), never a clean summary; otherwise RESULT is FAIL,
  PARTIAL or PASS.
- RELEASE_VERSION=checkout uses this checkout's chart and scripts (not with
  an OCI chart).
- Docs: scripts/selfhost/README.md (OCI-first), examples/aws README and the
  Secret 01-05 comments, docs/self-hosted-rds-manual-setup.md and
  docs/self-hosted-eks.md. Registry: opt.agent-relay.database-guard.

Tests: configure-rds-chart-test.sh 9/9. Its openssl mock now returns hex,
its kubectl mock answers Job status, and step 5 asserts that the layout is
in values.yaml with no hidden overlay. scripts/support tests 63/63.
configure-rds-e2e (kind + RDS-shaped PG17 with TLS, the rehearsal's
Secrets): the hand-filled install is refused up front, and the guided run
creates the logins, completes the migrations, mints the key and ends with
the verdict. A plain upgrade keeps rdsLayout. A fully healthy run needs S3
and OpenSearch, which the harness doesn't have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@khaliqgant
khaliqgant force-pushed the feat/selfhost-guided-install branch from 68dc817 to e5cdb39 Compare November 26, 2026 23:56
@khaliqgant

Copy link
Copy Markdown
Member Author

Rebuilt onto main after #555, #557, #558 and #559, as one commit on top of #554.

@khaliqgant
khaliqgant merged commit 8712427 into feat/selfhost-helm-test-status Nov 27, 2026
11 checks passed
@khaliqgant
khaliqgant deleted the feat/selfhost-guided-install branch November 27, 2026 01:46
khaliqgant added a commit that referenced this pull request Nov 27, 2026
… guided configure-rds.sh (agent-relay 0.7.86, sessions-pipeline 0.8.62)

Rebuilt on main after #553 (chart-managed RDS CA) and #548, which took
agent-relay 0.7.85 and sessions-pipeline 0.8.61, so this PR moves to
0.7.86 and 0.8.62. It includes #556 (guided configure-rds.sh), which was
merged into this PR's branch. #553 already updated databaseGuard for the
chart-managed CA: a hook-scoped copy of the bundle, because rds-ca is
created after the pre-install hook. The status test reuses those helpers.

helm test (agent-relay):
- `helm test <release> -n <namespace> --logs` runs a status Pod (relaycast
  image) and prints one ok/FAIL/skip table and a HEALTHY/UNHEALTHY verdict:
  - database logins: the databaseGuard rules, plus USAGE on sessions for the
    HoopDb runtime, read API, ingest and search logins (the rehearsal's
    "permission denied for schema sessions");
  - each CA (kind/name/key) against its pins;
  - S3 for the AWS provider only, and OpenSearch reachability;
  - with databaseGuard.statusTest.rbac.create (off by default: the
    documented operator Role can't create Roles) also:
    - the newest Job of each kind; CronJob runs are excluded, and a failed
      search bootstrap shows its recorded cause plus the recovery steps;
    - Deployments on the current revision;
    - Pod Identity checked per pod.
- databaseGuard also refuses an unset worker.migrations.rdsLayout with a
  dedicated HoopDb owner when chart migrations are on. This covers a plain
  upgrade that dropped configure-rds.sh's overlay (rds_profile_unproven).

Search bootstrap (sessions-pipeline):
- The guard names the cause: a LOGIN wait timeout, an unactivated search
  login, or any SearchIndexError (OpenSearch unreachable, no AWS
  credentials, a 403). It writes the cause to the termination message
  (FallbackToLogsOnError).
- The search indexer gets POD_NAMESPACE for its startup hint.

configure-rds.sh (from #556):
- the guided, primary install path, with the OCI chart or a checkout;
- generates the app keys and never replaces existing ones; writes the five
  Secrets;
- writes the HoopDb layout, first admin and status RBAC into the values file
  instead of a hidden overlay;
- Job waits stop at Complete or Failed; a failed search bootstrap is shown,
  deleted and re-run after post;
- --reset-databases checks ownership before dropping anything;
- ends with helm test, the diagnostic, a HEALTHY/UNHEALTHY/INCOMPLETE line and
  Next steps; first sign-in waits for the relay-control rollout;
- diagnose-install.py ends with a RESULT line, and skipped workload checks
  are INCOMPLETE (exit 3).

Tests: kind db-guard e2e 19/19 on this tree (with #553's CA changes),
ci/rds-ca/test.sh 57 checks, chart static, render, profile matrix, local
stack, subdomain goldens (Helm v4.3.1), registry check, support tests,
bootstrap guard tests 10/10, version-bump check. Chart.lock changes only
the sessions-pipeline version and the lock digest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
khaliqgant added a commit that referenced this pull request Nov 27, 2026
… guided configure-rds.sh (agent-relay 0.7.86, sessions-pipeline 0.8.62)

Rebuilt on main after #553 (chart-managed RDS CA) and #548, which took
agent-relay 0.7.85 and sessions-pipeline 0.8.61, so this PR moves to
0.7.86 and 0.8.62. It includes #556 (guided configure-rds.sh), which was
merged into this PR's branch. #553 already updated databaseGuard for the
chart-managed CA: a hook-scoped copy of the bundle, because rds-ca is
created after the pre-install hook. The status test reuses those helpers.

helm test (agent-relay):
- `helm test <release> -n <namespace> --logs` runs a status Pod (relaycast
  image) and prints one ok/FAIL/skip table and a HEALTHY/UNHEALTHY verdict:
  - database logins: the databaseGuard rules, plus USAGE on sessions for the
    HoopDb runtime, read API, ingest and search logins (the rehearsal's
    "permission denied for schema sessions");
  - each CA (kind/name/key) against its pins;
  - S3 for the AWS provider only, and OpenSearch reachability;
  - with databaseGuard.statusTest.rbac.create (off by default: the
    documented operator Role can't create Roles) also:
    - the newest Job of each kind; CronJob runs are excluded, and a failed
      search bootstrap shows its recorded cause plus the recovery steps;
    - Deployments on the current revision;
    - Pod Identity checked per pod.
- databaseGuard also refuses an unset worker.migrations.rdsLayout with a
  dedicated HoopDb owner when chart migrations are on. This covers a plain
  upgrade that dropped configure-rds.sh's overlay (rds_profile_unproven).

Search bootstrap (sessions-pipeline):
- The guard names the cause: a LOGIN wait timeout, an unactivated search
  login, or any SearchIndexError (OpenSearch unreachable, no AWS
  credentials, a 403). It writes the cause to the termination message
  (FallbackToLogsOnError).
- The search indexer gets POD_NAMESPACE for its startup hint.

configure-rds.sh (from #556):
- the guided, primary install path, with the OCI chart or a checkout;
- generates the app keys and never replaces existing ones; writes the five
  Secrets;
- writes the HoopDb layout, first admin and status RBAC into the values file
  instead of a hidden overlay;
- Job waits stop at Complete or Failed; a failed search bootstrap is shown,
  deleted and re-run after post;
- --reset-databases checks ownership before dropping anything;
- ends with helm test, the diagnostic, a HEALTHY/UNHEALTHY/INCOMPLETE line and
  Next steps; first sign-in waits for the relay-control rollout;
- diagnose-install.py ends with a RESULT line, and skipped workload checks
  are INCOMPLETE (exit 3).

Tests: kind db-guard e2e 19/19 on this tree (with #553's CA changes),
ci/rds-ca/test.sh 57 checks, chart static, render, profile matrix, local
stack, subdomain goldens (Helm v4.3.1), registry check, support tests,
bootstrap guard tests 10/10, version-bump check. Chart.lock changes only
the sessions-pipeline version and the lock digest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
khaliqgant added a commit that referenced this pull request Nov 27, 2026
… guided configure-rds.sh (agent-relay 0.7.87, sessions-pipeline 0.8.62) (#554)

* feat(agent-relay): helm test install status, search bootstrap causes, guided configure-rds.sh (agent-relay 0.7.86, sessions-pipeline 0.8.62)

Rebuilt on main after #553 (chart-managed RDS CA) and #548, which took
agent-relay 0.7.85 and sessions-pipeline 0.8.61, so this PR moves to
0.7.86 and 0.8.62. It includes #556 (guided configure-rds.sh), which was
merged into this PR's branch. #553 already updated databaseGuard for the
chart-managed CA: a hook-scoped copy of the bundle, because rds-ca is
created after the pre-install hook. The status test reuses those helpers.

helm test (agent-relay):
- `helm test <release> -n <namespace> --logs` runs a status Pod (relaycast
  image) and prints one ok/FAIL/skip table and a HEALTHY/UNHEALTHY verdict:
  - database logins: the databaseGuard rules, plus USAGE on sessions for the
    HoopDb runtime, read API, ingest and search logins (the rehearsal's
    "permission denied for schema sessions");
  - each CA (kind/name/key) against its pins;
  - S3 for the AWS provider only, and OpenSearch reachability;
  - with databaseGuard.statusTest.rbac.create (off by default: the
    documented operator Role can't create Roles) also:
    - the newest Job of each kind; CronJob runs are excluded, and a failed
      search bootstrap shows its recorded cause plus the recovery steps;
    - Deployments on the current revision;
    - Pod Identity checked per pod.
- databaseGuard also refuses an unset worker.migrations.rdsLayout with a
  dedicated HoopDb owner when chart migrations are on. This covers a plain
  upgrade that dropped configure-rds.sh's overlay (rds_profile_unproven).

Search bootstrap (sessions-pipeline):
- The guard names the cause: a LOGIN wait timeout, an unactivated search
  login, or any SearchIndexError (OpenSearch unreachable, no AWS
  credentials, a 403). It writes the cause to the termination message
  (FallbackToLogsOnError).
- The search indexer gets POD_NAMESPACE for its startup hint.

configure-rds.sh (from #556):
- the guided, primary install path, with the OCI chart or a checkout;
- generates the app keys and never replaces existing ones; writes the five
  Secrets;
- writes the HoopDb layout, first admin and status RBAC into the values file
  instead of a hidden overlay;
- Job waits stop at Complete or Failed; a failed search bootstrap is shown,
  deleted and re-run after post;
- --reset-databases checks ownership before dropping anything;
- ends with helm test, the diagnostic, a HEALTHY/UNHEALTHY/INCOMPLETE line and
  Next steps; first sign-in waits for the relay-control rollout;
- diagnose-install.py ends with a RESULT line, and skipped workload checks
  are INCOMPLETE (exit 3).

Tests: kind db-guard e2e 19/19 on this tree (with #553's CA changes),
ci/rds-ca/test.sh 57 checks, chart static, render, profile matrix, local
stack, subdomain goldens (Helm v4.3.1), registry check, support tests,
bootstrap guard tests 10/10, version-bump check. Chart.lock changes only
the sessions-pipeline version and the lock digest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(agent-relay): status review fixes (no old replicas in a done rollout, unbuildable URLs become rows, pins from running components only)

CodeRabbit on #554:
- A Deployment row is ok only when status.replicas equals updatedReplicas: old-revision
  pods still count as ready and available, so a one-replica stuck rollout read ok.
- reach() catches https.request construction errors (e.g. an http:// URL) and turns
  them into a FAIL row instead of rejecting and aborting the table.
- CA pins come only from components that run (worker always; read API, ingest and
  search indexer when enabled), so a disabled component's stale hash can't fail a
  valid bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(agent-relay): update subdomain goldens for the status script change (Helm v4.3.1)

Only the status ConfigMap's script content changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant