mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-26 10:16:53 +00:00
feat: health-gated updates and rollback readiness (#1354)
* feat: classify stack deploy and update failures with suggested next actions Failed deploy and update responses now carry a failure classification (cause category, headline, and suggested next step) derived from the compose error output. The recovery panel and chip render the classification and include it in copied diagnostics, and gateway-style failures surface as a node-unreachable cause. * feat: add update and rollback readiness reports for stacks Before a manual update, Sencho now shows an advisory readiness verdict computed from the stored preflight result, open drift findings, live container health, the pending image change, the rollback backup slot, and node disk headroom. The Stack Dossier gains a rollback readiness section that states what a rollback can restore and explicitly discloses that volume and bind-mounted data are not covered. Toolbar and sidebar updates now share one update path, and admins can create a fleet snapshot from the readiness dialog before updating. Nodes that do not advertise the capability keep the direct update flow. * feat: observe stack health after updates with a post-deploy health gate After a deploy or update succeeds, Sencho now watches the stack for a configurable observation window and records a passed, failed, or unknown verdict: containers must stay running, healthchecks must report healthy, and restart loops or disappearing containers fail the gate. The deploy panel shows the observation live and holds off auto-closing until the verdict lands, a failed gate surfaces the existing recovery actions including rollback, and the stack timeline records update started and gate verdict events. Scheduled, webhook, bulk, and git-source updates are gated the same way; rollbacks and installs are deliberately not. The gate is observational only and can be tuned or disabled per node under host alert settings. * docs: document health-gated updates and rollback readiness New operator page covering the update readiness dialog, the post-update health gate and its settings, the rollback readiness disclosure, and classified failures, with cross-links from the atomic deployments and deploy progress pages. The API reference gains the readiness and health-gate endpoints, the healthGateId success field, and the failure classification schema on deploy and update error responses. * feat: withhold the success verdict while the health gate observes An update used to show a green Succeeded that a failed health gate then contradicted moments later. The deploy modal now reports Verifying health while the gate observes, shows success only when the gate passes, and makes a failed or unknown gate the headline result; success toasts soften to a verifying message while a gate runs. The mobile recovery card groups its actions behind one bottom-right Take action menu so it stays compact on a phone, with the classified cause still visible on the card. A successful image update now also counts as the last known-good marker in rollback readiness, and the docs gain screenshots of the readiness dialog, gate states, dossier section, and settings. * fix: harden log format strings and the env existence path check Log calls that interpolated the stack name into the console format string now use constant format strings with placeholder arguments, and envExists validates path containment inline at its filesystem access, matching the established patterns used elsewhere in the same files. * test: adapt deploy modal success specs to the post-deploy health gate The deploy feedback modal now withholds its success verdict while the health gate observes the new containers, showing "Verifying health" until the gate passes. The two success-path E2E tests waited for "Succeeded" within the gate's 90s default window and timed out. Shorten the observation window to the 15s minimum for these tests via the settings API, assert the verify-then-succeed sequence the modal actually renders, and restore the default window afterward so the test value does not leak into later runs. * fix: serialize health gate polling and harden gate observation Address race conditions in the post-update health gate found in review. Backend: the gate poller used setInterval, so a Docker observe slower than the 5s tick could overlap the next poll and corrupt the restart and missing-container accounting, and a wedged socket could leave a poll pending forever. Polling is now single-flight: each cycle self-schedules the next only after it settles, and the observe is bounded by an 8s timeout so a hung probe counts as a poll error and resolves the gate unknown after three in a row. Frontend: the gate poller could overlap requests, letting a slow earlier "observing" response overwrite an already-applied terminal verdict. It is now single-flight with a terminal latch, so a late response can never roll the UI back from passed or failed. Also reject a non-digit nodeId on the snapshot coverage route instead of letting parseInt coerce it, document that turning off the deploy progress panel opts out of the live gate UI while the gate still runs server-side, and add gate-coverage tests for the webhook, git source, and auto-update apply paths plus the new single-flight, observe-timeout, and recovery cases.
This commit is contained in:
+232
-3
@@ -149,6 +149,32 @@ components:
|
||||
type: boolean
|
||||
example: true
|
||||
|
||||
FailureClassification:
|
||||
type: object
|
||||
description: Classified cause of a failed deploy or update, with a suggested next step.
|
||||
required: [reason, label, suggestion]
|
||||
properties:
|
||||
reason:
|
||||
type: string
|
||||
enum:
|
||||
- image_pull_failed
|
||||
- compose_render_failed
|
||||
- env_missing
|
||||
- port_conflict
|
||||
- bind_path_missing
|
||||
- permission_denied
|
||||
- container_exited
|
||||
- healthcheck_failed
|
||||
- dependency_unavailable
|
||||
- node_unreachable
|
||||
- unknown
|
||||
label:
|
||||
type: string
|
||||
description: Short display headline for the cause.
|
||||
suggestion:
|
||||
type: string
|
||||
description: Suggested next action, one sentence.
|
||||
|
||||
Container:
|
||||
type: object
|
||||
properties:
|
||||
@@ -945,9 +971,19 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/SuccessMessage"
|
||||
example:
|
||||
message: Deployed successfully
|
||||
type: object
|
||||
required: [message]
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
example: Deployed successfully
|
||||
healthGateId:
|
||||
type: string
|
||||
nullable: true
|
||||
description: |
|
||||
Id of the post-deploy health gate observation started for
|
||||
this deploy, for use with the health-gate endpoint. Null
|
||||
when the health gate is disabled on the node.
|
||||
"403":
|
||||
$ref: "#/components/responses/Forbidden"
|
||||
"500":
|
||||
@@ -963,6 +999,8 @@ paths:
|
||||
rolledBack:
|
||||
type: boolean
|
||||
description: Whether the stack was automatically rolled back.
|
||||
failure:
|
||||
$ref: "#/components/schemas/FailureClassification"
|
||||
|
||||
/api/stacks/{stackName}/down:
|
||||
post:
|
||||
@@ -1095,6 +1133,13 @@ paths:
|
||||
status:
|
||||
type: string
|
||||
example: Update completed
|
||||
healthGateId:
|
||||
type: string
|
||||
nullable: true
|
||||
description: |
|
||||
Id of the post-update health gate observation started for
|
||||
this update, for use with the health-gate endpoint. Null
|
||||
when the health gate is disabled on the node.
|
||||
"403":
|
||||
$ref: "#/components/responses/Forbidden"
|
||||
"500":
|
||||
@@ -1109,6 +1154,8 @@ paths:
|
||||
type: string
|
||||
rolledBack:
|
||||
type: boolean
|
||||
failure:
|
||||
$ref: "#/components/schemas/FailureClassification"
|
||||
|
||||
/api/stacks/{stackName}/rollback:
|
||||
post:
|
||||
@@ -1169,6 +1216,188 @@ paths:
|
||||
"500":
|
||||
$ref: "#/components/responses/InternalError"
|
||||
|
||||
/api/stacks/{stackName}/update-readiness:
|
||||
get:
|
||||
operationId: getStackUpdateReadiness
|
||||
tags: [Stacks]
|
||||
summary: Check update readiness
|
||||
description: |
|
||||
Computes an advisory readiness verdict for updating the stack right
|
||||
now, from the stored preflight result, open drift findings, live
|
||||
container health, the pending image change, the rollback backup slot,
|
||||
and node disk headroom. Advisory only: no verdict blocks an update.
|
||||
Requires `stack:read` permission.
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/stackName"
|
||||
- $ref: "#/components/parameters/nodeId"
|
||||
responses:
|
||||
"200":
|
||||
description: Readiness report.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required: [stack, computedAt, verdict, signals]
|
||||
properties:
|
||||
stack:
|
||||
type: string
|
||||
computedAt:
|
||||
type: integer
|
||||
description: Unix timestamp (ms) the report was computed.
|
||||
verdict:
|
||||
type: string
|
||||
enum: [ready, ready_with_warnings, review_required, blocked, unknown]
|
||||
signals:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required: [id, status, title, detail, affectsVerdict]
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
enum: [ok, warning, attention, blocked, unknown]
|
||||
title:
|
||||
type: string
|
||||
detail:
|
||||
type: string
|
||||
affectsVerdict:
|
||||
type: boolean
|
||||
"401":
|
||||
$ref: "#/components/responses/Unauthorized"
|
||||
"403":
|
||||
$ref: "#/components/responses/Forbidden"
|
||||
"500":
|
||||
$ref: "#/components/responses/InternalError"
|
||||
|
||||
/api/stacks/{stackName}/rollback-readiness:
|
||||
get:
|
||||
operationId: getStackRollbackReadiness
|
||||
tags: [Stacks]
|
||||
summary: Check rollback readiness
|
||||
description: |
|
||||
Reports what a rollback of this stack can actually restore: the backed
|
||||
up compose file, env coverage (variable names only, never values), the
|
||||
known previous image tag, and an explicit disclosure that volume and
|
||||
bind-mounted data are not covered by file backups.
|
||||
Requires `stack:read` permission.
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/stackName"
|
||||
- $ref: "#/components/parameters/nodeId"
|
||||
responses:
|
||||
"200":
|
||||
description: Rollback readiness report.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required: [stack, computedAt, overall, items]
|
||||
properties:
|
||||
stack:
|
||||
type: string
|
||||
computedAt:
|
||||
type: integer
|
||||
overall:
|
||||
type: string
|
||||
enum: [ready, partial, not_ready]
|
||||
items:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required: [id, state, label, detail]
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
state:
|
||||
type: string
|
||||
enum: [ready, missing, unknown, not_covered]
|
||||
label:
|
||||
type: string
|
||||
detail:
|
||||
type: string
|
||||
"401":
|
||||
$ref: "#/components/responses/Unauthorized"
|
||||
"403":
|
||||
$ref: "#/components/responses/Forbidden"
|
||||
"500":
|
||||
$ref: "#/components/responses/InternalError"
|
||||
|
||||
/api/stacks/{stackName}/health-gate:
|
||||
get:
|
||||
operationId: getStackHealthGate
|
||||
tags: [Stacks]
|
||||
summary: Get post-update health gate result
|
||||
description: |
|
||||
Returns a post-deploy health gate observation for the stack: the run
|
||||
named by `gateId` (as returned in a deploy or update response), or the
|
||||
most recent run when omitted. Status `never-run` means no observation
|
||||
exists. Requires `stack:read` permission.
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/stackName"
|
||||
- $ref: "#/components/parameters/nodeId"
|
||||
- name: gateId
|
||||
in: query
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
description: A specific gate run id to read instead of the latest.
|
||||
responses:
|
||||
"200":
|
||||
description: Health gate report.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required: [stack, status]
|
||||
properties:
|
||||
stack:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
nullable: true
|
||||
status:
|
||||
type: string
|
||||
enum: [observing, passed, failed, unknown, never-run]
|
||||
trigger:
|
||||
type: string
|
||||
nullable: true
|
||||
enum: [update, deploy, null]
|
||||
reason:
|
||||
type: string
|
||||
nullable: true
|
||||
windowSeconds:
|
||||
type: integer
|
||||
nullable: true
|
||||
startedAt:
|
||||
type: integer
|
||||
nullable: true
|
||||
endedAt:
|
||||
type: integer
|
||||
nullable: true
|
||||
containers:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required: [name, state, restarts]
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
state:
|
||||
type: string
|
||||
description: Docker container state, or `missing` when it vanished mid-observation.
|
||||
health:
|
||||
type: string
|
||||
nullable: true
|
||||
restarts:
|
||||
type: integer
|
||||
"401":
|
||||
$ref: "#/components/responses/Unauthorized"
|
||||
"403":
|
||||
$ref: "#/components/responses/Forbidden"
|
||||
"500":
|
||||
$ref: "#/components/responses/InternalError"
|
||||
|
||||
|
||||
# ── Containers ──────────────────────────────────────────
|
||||
/api/containers:
|
||||
|
||||
Reference in New Issue
Block a user