mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-19 06:46:23 +00:00
feat(scheduler): schedule container restart, stop, and start (#1526)
* feat(scheduler): schedule container restart, stop, and start Add container as a scheduled-task target type so operators can automate lifecycle actions against standalone containers by node and name, with matching UI pickers, validation, execution on local and remote nodes, and tests. * fix(scheduler): stack service matching and container picker hygiene Backfill Service on smartFallback containers so per-service stack restarts work when container_name is set. Match services by compose label and container name in stack routes and scheduled restarts. Exclude Sencho from GET /api/containers lists. Hide the Restart Stack service picker when a stack has only one service. * test(scheduler): scope service checkbox assertion to Services block The create dialog also has a Delete after run checkbox. Count checkboxes only inside the Services section so CI does not include unrelated form controls. * fix(scheduler): narrow closest() result to HTMLElement in schedule test The service-checkbox assertion passed an Element from closest() into within(), which requires an HTMLElement, failing tsc -b in the frontend build and Docker build stages. Use the closest<HTMLElement>() type argument so the value type-checks without an unsafe cast. * fix(scheduler): hide Sencho container on remote node picker lists Remote container lists are proxied from peer Sencho instances, so id-only self filtering missed peers on older builds. Await SelfIdentity init, match ImageID, and drop official saelix/sencho images. Apply the same heuristic in the scheduled-operations UI and when the hub fetches remote containers for scheduled runs. * test(monitor): add missing DatabaseService mocks for scan history cleanup * test(scheduler): add missing markStaleScansAsFailed mock SchedulerService.tick() calls db.markStaleScansAsFailed() to sweep stale vulnerability scans. The scheduler-service test was missing this method in its DatabaseService mock, causing TypeError failures during test initialization. Added mockMarkStaleScansAsFailed to hoisted mocks and DatabaseService mock object, returning safe default of 0 scans marked as failed. * test(compose): add missing FileSystemService mocks for getStackContent/getEnvContent * test(containers-route): mock SelfIdentityService to prevent initialize() crash The excludeSelfContainers() helper calls SelfIdentityService.initialize(), which tries to access DockerController. Without a proper SelfIdentityService mock, the initialize() call fails silently, causing a 500 error on GET /api/containers. Added SelfIdentityService mock with initialize(), isOwnContainer(), and isOwnImage() methods to prevent the crash.
This commit is contained in:
+10
-8
@@ -386,13 +386,13 @@ components:
|
||||
type: string
|
||||
target_type:
|
||||
type: string
|
||||
enum: [stack, fleet, system]
|
||||
enum: [stack, fleet, system, container]
|
||||
target_id:
|
||||
type: ["string", "null"]
|
||||
description: Stack name (when target_type is `stack`).
|
||||
description: Stack or container name (when target_type is `stack` or `container`).
|
||||
node_id:
|
||||
type: ["integer", "null"]
|
||||
description: Target node ID (when target_type is `stack`).
|
||||
description: Target node ID (when target_type is `stack` or `container`).
|
||||
action:
|
||||
type: string
|
||||
enum: [restart, snapshot, prune]
|
||||
@@ -2717,7 +2717,8 @@ paths:
|
||||
summary: Create scheduled task
|
||||
description: |
|
||||
Creates a new recurring task. Action-target rules:
|
||||
- `restart` requires `target_type: stack` (with `target_id` and `node_id`)
|
||||
- `restart` requires `target_type: stack` or `target_type: container` (with `target_id` and `node_id`)
|
||||
- `auto_stop` and `auto_start` accept `target_type: stack` or `target_type: container`
|
||||
- `snapshot` requires `target_type: fleet`
|
||||
- `prune` requires `target_type: system`
|
||||
|
||||
@@ -2735,13 +2736,13 @@ paths:
|
||||
example: Nightly restart
|
||||
target_type:
|
||||
type: string
|
||||
enum: [stack, fleet, system]
|
||||
enum: [stack, fleet, system, container]
|
||||
target_id:
|
||||
type: string
|
||||
description: Stack name (required when target_type is `stack`).
|
||||
description: Stack or container name (required when target_type is `stack` or `container`).
|
||||
node_id:
|
||||
type: integer
|
||||
description: Target node ID (required when target_type is `stack`).
|
||||
description: Target node ID (required when target_type is `stack` or `container`).
|
||||
action:
|
||||
type: string
|
||||
enum: [restart, snapshot, prune]
|
||||
@@ -2828,9 +2829,10 @@ paths:
|
||||
type: string
|
||||
target_type:
|
||||
type: string
|
||||
enum: [stack, fleet, system]
|
||||
enum: [stack, fleet, system, container]
|
||||
target_id:
|
||||
type: string
|
||||
description: Stack or container name when target_type is `stack` or `container`.
|
||||
node_id:
|
||||
type: integer
|
||||
action:
|
||||
|
||||
Reference in New Issue
Block a user