dev: maintenance
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
# Project tasks
|
||||
|
||||
| ID | Task | Status |
|
||||
| --- | --- | --- |
|
||||
| WM-001 | [Automate the Docker shutdown integration test](WM-001-docker-shutdown-test.md) | Todo |
|
||||
| WM-002 | [Add a non-init supervisor mode](WM-002-non-init-supervisor-mode.md) | Todo |
|
||||
|
||||
Give each new task a stable ID and a Markdown file with acceptance criteria. Use **Todo**, **In progress**, or **Done** in this index.
|
||||
@@ -0,0 +1,49 @@
|
||||
# WM-001: Automate the Docker shutdown integration test
|
||||
|
||||
Shutdown is currently tested manually in Docker. Wingmate is designed to act as Linux init: it broadcasts shutdown signals so that even orphaned descendants receive them. Add an opt-in test runner that verifies real signal delivery in disposable containers. The runner must work on a separate Linux test machine without a coding agent and produce a portable diagnostic bundle for analysis back in the development environment.
|
||||
|
||||
## Scope
|
||||
|
||||
### In scope
|
||||
|
||||
- A shell runner, disposable child fixtures, and test-specific Docker setup to build and test the current checkout on Linux.
|
||||
- Two shutdown scenarios in isolated containers: a child that exits on TERM and a child that stays alive after TERM until Wingmate escalates.
|
||||
- A portable diagnostic archive and instructions for running the test, finding its results, and bringing them back to the development environment.
|
||||
|
||||
### Out of scope
|
||||
|
||||
- Changes to Wingmate's production shutdown behavior or PID 1 enforcement.
|
||||
- Unit-test refactors, CI wiring, and support for other container engines.
|
||||
- General supervisor coverage, including service restarts, cron scheduling, and orphan reaping.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] Provide a standalone shell script with one documented command that builds Wingmate from the current checkout and runs the test on a Linux Docker engine. Document the prerequisites and how to copy the result back. Running `go test ./...` alone does not invoke this test.
|
||||
- [ ] Start Wingmate directly as PID 1 in a dedicated container PID namespace. Verify that it is PID 1 before sending any shutdown signal. Do not use Docker's `--init`, host PID mode, or another container's PID namespace.
|
||||
- [ ] In a fresh container with a cooperative child, wait for an explicit readiness marker, send `SIGTERM` to Wingmate through Docker, and verify that the child received `SIGTERM` and Wingmate exited without escalating.
|
||||
- [ ] In a fresh container with a TERM-resistant child, verify that the child receives `SIGTERM` and stays alive until Wingmate escalates to `SIGKILL`. Send `SIGTERM` without scheduling a Docker fallback kill, and require the container to exit before the test timeout and before forced cleanup.
|
||||
- [ ] Bound readiness and shutdown waits. Collect diagnostics before removing containers on success or failure. Preserve partial diagnostics if the build fails, a case times out, or a container never starts.
|
||||
- [ ] Print a concise result for each case and the path to a timestamped diagnostic archive in a caller-selectable output directory. Return a nonzero exit status if setup fails, a case fails, or a case times out.
|
||||
|
||||
## Diagnostic bundle
|
||||
|
||||
The archive should be usable without access to the test machine or the original containers. Include:
|
||||
|
||||
- A plain-text summary with the result of each case, the first failed assertion with expected and actual results, and whether any cases could not run.
|
||||
- The Git revision and whether the checkout was dirty, the Docker client and engine versions, and the test platform and architecture.
|
||||
- Build output and timestamped container logs for each case, including Wingmate and child output.
|
||||
- A timestamped record of the PID 1 and readiness checks, when TERM was sent, any observed escalation, the container exit status, and whether a timeout or forced cleanup occurred.
|
||||
|
||||
Capture only the configuration and container metadata needed to diagnose the run. Keep host environment variables and Docker credentials out of the archive.
|
||||
|
||||
## Implementation notes
|
||||
|
||||
- Use a readiness marker that the child emits after installing its TERM handler. Wait for the marker with a deadline rather than sleeping for a fixed interval.
|
||||
- Have the TERM-resistant fixture log that it received TERM while continuing to run. Use Wingmate's `start pumping SIGKILL signal` log and the container's exit as evidence of escalation; a container exit alone is insufficient.
|
||||
- Record the shutdown outcome before forced cleanup so cleanup cannot turn a timeout into a pass. Keep the logs from failures that occur before either shutdown scenario starts.
|
||||
- Use UTC timestamps across the event timeline and logs so they can be compared after the archive is copied to another machine.
|
||||
|
||||
## Relevant code
|
||||
|
||||
- [Signal handler](../../init/sighandler.go) and [shutdown escalation](../../init/signal-pump.go)
|
||||
- [Bookworm Dockerfile](../../docker/bookworm/Dockerfile) and [entrypoint](../../docker/bookworm/entry.sh)
|
||||
@@ -0,0 +1,32 @@
|
||||
# WM-002: Add a non-init supervisor mode
|
||||
|
||||
Let Wingmate run as an ordinary Linux process under an existing init system, in the spirit of Python's Supervisor. It should start and restart configured programs and shut down only the workloads it owns. The existing container init mode remains the default.
|
||||
|
||||
## Scope
|
||||
|
||||
### In scope
|
||||
|
||||
- An explicit opt-in mode for running Wingmate in the foreground as a regular user, without being PID 1.
|
||||
- Start, monitor, and restart foreground services using existing YAML and shell-script configurations. Keep existing cron scheduling for supported foreground jobs and apply the same shutdown rules to running jobs.
|
||||
- Track and reap Wingmate's own child processes. Send shutdown signals only to managed workloads, including descendants that remain in a process group Wingmate created for the workload.
|
||||
- Document how to select the mode, what it can supervise, and how to configure programs to stay in the foreground.
|
||||
|
||||
### Out of scope
|
||||
|
||||
- Changes to PID 1 shutdown behavior or the [PID 1 Docker test](WM-001-docker-shutdown-test.md).
|
||||
- Full Supervisor compatibility, including its configuration format, control socket, web UI, and `supervisorctl`.
|
||||
- Managing unrelated processes or adopting detached daemons. Supporting PID-file proxying and commands that create a separate session in this mode is deferred.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] A documented option starts Wingmate as a non-PID-1, unprivileged Linux process. Existing container invocations still select init mode by default.
|
||||
- [ ] A configured foreground service starts and restarts after an unexpected exit. When Wingmate begins shutting down, it stops starting new services and cron jobs, and it does not restart processes that exit during shutdown.
|
||||
- [ ] On shutdown, Wingmate sends TERM to its managed workloads, waits for a bounded grace period, and sends KILL only to managed workloads that remain. It never broadcasts signals or uses a catch-all child reaper in this mode.
|
||||
- [ ] Unsupported task options, such as `pidfile` and `setsid`, produce a clear error naming the task before any workload starts.
|
||||
- [ ] Tests cover restart, graceful shutdown, and escalation. A Linux integration test runs Wingmate as non-PID 1 inside an isolated PID namespace and verifies that an unrelated process in the same namespace survives both shutdown paths.
|
||||
|
||||
## Implementation notes
|
||||
|
||||
- Give each workload its own process group at launch. Wingmate and unrelated processes must stay outside those groups.
|
||||
- Assign one owner to wait for each direct child. Keep init-mode orphan reaping separate from the non-init execution path.
|
||||
- Synchronize process starts with shutdown so a child cannot start after shutdown has taken its list of workloads to stop.
|
||||
Reference in New Issue
Block a user