feat(admin): #1078 headless POST /api/cluster/failover (key-gated, same service+audit) and unattended SCM-restart gate

fix(install): #1075 worker identity gets read+execute (not Modify) on <PeCacheDir>\pe; re-run replaces the old grant
This commit is contained in:
Joseph Doherty
2026-12-03 16:29:27 -05:00
parent fe4bbbe256
commit 762bcd7b8d
10 changed files with 229 additions and 12 deletions
+4
View File
@@ -1831,6 +1831,10 @@ Responses: `202 Accepted` (`{ outcome, deploymentId, revisionHash }`) when a dep
**Outcome unknown (lmxopcua#949).** The trigger waits 10 s for the admin singleton. A slow compose (one gate run took 10.5 s) can outlast that and still create and apply the deployment, so a timeout is **not** reported as a failure: the id is pre-allocated before the ask and the response is `202 Accepted` with `{ "outcome": "OutcomeUnknown", "deploymentId": "<id>", "message": "…" }` and `Location: /api/deployments/<id>`. Poll that resource: `200` means the deployment exists (and carries exactly that id); `404` for a couple of minutes means it was not created and the trigger can be repeated (a repeat while the original compose is still running answers `409` naming the same id). Scripts must therefore check `outcome`, not just the 2xx status. The AdminUI Deployments page shows the same case as "could not be confirmed … may still be created", with the id. The admin singleton logs a Warning with the per-phase timings (`dispatch`, `in-flight-check`, `snapshot-begin+compose-lock`, `snapshot-read`, `validate`, `compose`, `save+commit`), timed from the singleton's receipt of the request, for any deploy slower than 3 s. Since lmxopcua#955 the compose reads under SNAPSHOT isolation (serialised against other composes by an app lock), not SERIALIZABLE: a concurrent AdminUI edit neither waits for a running deploy nor holds it, and the two can no longer deadlock (under SERIALIZABLE a cross-table edit made the deploy wait ~5 s per deadlock-monitor cycle or fail with "StartDeployment failed on the server"). An edit that commits after the deploy's snapshot is simply in the next deployment. Set the secret via `Security:DeployApiKey` (env `Security__DeployApiKey`) on admin nodes only; treat it like any deploy credential (rotate, keep out of source).
### Headless manual failover (`POST /api/cluster/failover`, lmxopcua#1078)
Admin-role nodes also expose the cluster redundancy page's "Trigger failover" action to scripts (`ManualFailoverApiEndpoints`), calling the same `IManualFailoverService` (peer guard + `cluster.manual-failover` audit; see `docs/Redundancy.md` §"Manual failover"). Same shape as the deploy API: `AllowAnonymous` + a handler-checked `X-Api-Key` against **`Security:FailoverApiKey`** (env `Security__FailoverApiKey`), fixed-time, self-disabling (`503`) until set. It is deliberately a **different key from `Security:DeployApiKey`** — the page requires `FleetAdmin` because it restarts a production node, so a deploy credential must not grant it. `401` wrong/missing key, `409` no peer, `202` accepted. Optional `X-Actor` header is appended to the audit actor. Treat the key as an Administrator credential (rotate, never commit).
### `/fleet/diagnostics` dials only known nodes (#973 / review A-1)
The page used to feed `?node=` (or the typed host:port box) straight into an Akka `ActorSelection`, so any signed-in user could make the admin node open an outbound remoting association to an arbitrary `host:port`. The target now resolves server-side through `FleetDiagnosticsTargets.Resolve` against a closed set: **Up driver-role cluster members ∪ `Host:AkkaPort` of every enabled `ClusterNode`**. Anything else renders "Unknown node … no connection was attempted" and never reaches `IFleetDiagnosticsClient`; the value dialled is the canonical member string, not the caller's text. Peer nodes for the cluster-wide Faulted tile go through the same check. `FleetDiagnosticsClient` independently refuses any value that is not a plain `host:port` (`FleetDiagnosticsTargets.IsWellFormed`; `/`, `@`, whitespace, `?`, port outside 1..65535) before building the address.