feat(ha): wire opt-in production runtime - #875
Conversation
🔐 Codex Security Review
Review SummaryOverall Risk: NONE FindingsNo concrete security, correctness, or reliability issues were identified in the changed hunks. NotesThe HA configuration, authenticated database routing, ownership-loss cleanup, and runtime-job abort paths were reviewed. Targeted Go tests could not run because the read-only environment prevented creation of the module cache. Generated by Codex Security Review | |
e8c7bb1 to
3aa622e
Compare
3aa622e to
e39383b
Compare
e39383b to
73acc35
Compare
73acc35 to
4fded94
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4fded945d8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
4fded94 to
ad1e068
Compare
ad1e068 to
6079acd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6079acdede
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
6079acd to
8aeb834
Compare
62344dd to
1e938ec
Compare
1e938ec to
09c7f00
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09c7f0080b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
09c7f00 to
55d1429
Compare
55d1429 to
344b6a4
Compare
344b6a4 to
12a5765
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12a5765c94
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- validate HA timing and database routing at startup - require IP-addressed etcd endpoints and prepared HA queries - preserve abort-only shutdown after ownership loss
|
🤖
Addressed in |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8a939b023
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- validate HA timing and database routing at startup - require IP-addressed etcd endpoints and prepared HA queries - preserve abort-only shutdown after ownership loss
d8a939b to
5aaf0ee
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5aaf0eee77
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- validate persisted lease precision - hard-cancel and await fatal HA aborts
|
🤖
Addressed differently: fatal HA shutdown now hard-cancels command execution, schedule processing, and curtailment reconciliation before bounded stop/wait cleanup. Schedule and curtailment now implement |
|
🤖
Addressed: enabled HA now validates positive renew/retry intervals, requires renewal before lease expiry, and requires lease duration to use the same whole-millisecond precision persisted in PostgreSQL. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b1f7fc9d7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| g.endActivation() | ||
| g.setGroupState(StateStopping) | ||
| abortJobs(g.jobs) | ||
| return g.finishStop(ctx) |
There was a problem hiding this comment.
Avoid graceful Stop during HA aborts
Fresh evidence in this commit is that Group.Abort now calls finishStop, which invokes every job's Stop after abortJobs. During HA ownership loss or lease expiry, Runtime.abortGroup uses this path, but jobs that don't implement Aborter still run their graceful shutdown; for example TelemetryService has no Abort and its Stop waits for finishActivation, which flushes/requeues pending telemetry (server/internal/domain/telemetry/activation.go:153-168). That lets the old active process keep writing stale telemetry after a replacement has acquired ownership, so keep HA aborts to hard-cancel/wait-only cleanup or add abort semantics for these jobs.
Useful? React with 👍 / 👎.
Reviewable diff: +265/-17 across 4 files (excludes generated, test, and story files).
Summary
Fleet operators can opt a new deployment into the active/passive runtime through
FLEET_HA_*configuration. HA remains off by default, while enabled deployments now fail startup before connecting or migrating if lease timing, etcd addressing, database failover routing, or PostgreSQL server authentication is unsafe.Stack
This diff is relative to #874. The parent provides lease ownership, command restart recovery, fatal active-process exit, and active request admission. This PR selects and constructs that runtime from production configuration. Installer automation, rolling-upgrade migration coordination, and live three-host qualification remain outside this PR.
How it works
flowchart TD START["fleetd starts"] --> ENABLED{"FLEET_HA_ENABLED?"} ENABLED -->|"No"| STANDALONE["Standalone runtime"] ENABLED -->|"Yes"| VALIDATE["Validate timing, IP endpoints, and secure multi-host DB routing"] VALIDATE --> DB["Connect and migrate PostgreSQL"] DB --> CLIENTS["Create etcd and Patroni clients plus prepared HA queries"] CLIENTS --> PROOF["Compare DCS primary with connected PostgreSQL writer"] PROOF --> LEASE["Acquire Fleet active lease"] LEASE --> ACTIVE["Start active jobs and open admission"] ACTIVE --> LOSS{"Ownership lost?"} LOSS -->|"No, normal shutdown"| STOP["Gracefully stop jobs"] LOSS -->|"Yes"| ABORT["Abort jobs and exit process"]Areas of the code involved
server/cmd/fleetd/config.go,main.goserver/internal/ha/config.goserver/internal/infrastructure/db/config.goKey technical decisions & trade-offs
DB_DSN,target_session_attrs=read-write, and authenticated TLS instead of accepting legacy single-host fields or opportunistic encryption.Testing & validation
internal/ha, database configuration, andcmd/fleetdtests passed.