Skip to content

Launch controlled-session watchdog - #34

Open
omry wants to merge 1 commit into
pr33from
pr34
Open

Launch controlled-session watchdog#34
omry wants to merge 1 commit into
pr33from
pr34

Conversation

@omry

@omry omry commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • launch a short-lived watchdog child from the same Reploy executable after durable ownership is frozen and before either session container starts
  • isolate the watchdog in its own Linux process session so terminal group signals aimed at the attached operation do not kill both processes
  • use an inherited immutable manifest, readiness acknowledgement, and private parent-liveness pipe with no listener or later resource selection
  • on parent loss, verify boot and ownership labels, force-remove only the exact manifested containers, verify absence, and remove the private channel
  • disarm only after workload and delivery-tail cleanup succeed, with an independent final cleanup verification in the child
  • keep Docker-unavailability retry and restart reconciliation for the next crash-containment slices

Validation

  • go test ./...
  • focused go test -race for watchdog and supervisor lifecycle cases
  • go vet ./internal/dockerdeploy ./cmd/reploy
  • live Docker supervisor integration covering process-group isolation, normal disarm, and parent-pipe-loss cleanup
  • Windows and macOS cross-compilation checks

@omry
omry changed the base branch from main to pr33 August 9, 2026 12:50
@omry

omry commented Aug 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3cd3b535f

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/dockerdeploy/controlled_session_watchdog_linux.go
@omry

omry commented Aug 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: e62a808725

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@omry

omry commented Aug 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 838881d9fb

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@omry
omry marked this pull request as ready for review August 9, 2026 13:47
Copilot AI lite review requested due to automatic review settings August 9, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a Linux-only “controlled-session watchdog” launched as a short-lived child process from the same reploy executable. The watchdog receives an immutable cleanup manifest over inherited FDs, isolates itself into a separate process session, and performs verified cleanup on parent loss (and final verification on disarm), while the supervisor is updated to launch/disarm the watchdog as part of the controlled-session lifecycle.

Changes:

  • Add a controlled-session watchdog child mode with manifest decoding, boot/label verification, and cleanup enforcement.
  • Launch the watchdog from the controlled-session supervisor before starting either container, and disarm it only after verified cleanup succeeds.
  • Add unit + integration tests and update controlled-session design documentation and cmd/reploy entrypoint dispatch.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/dockerdeploy/controlled_session_watchdog.go Watchdog core logic: manifest read/validate, boot/label checks, container/channel cleanup, Docker inspect/remove backend.
internal/dockerdeploy/controlled_session_watchdog_linux.go Linux watchdog process launch, readiness handshake, setsid isolation, disarm + wait.
internal/dockerdeploy/controlled_session_watchdog_unsupported.go Non-Linux stubs returning “requires Linux”.
internal/dockerdeploy/controlled_session_watchdog_test.go Unit tests for watchdog behavior (disarm verification, parent-loss cleanup, boot/label guarding).
internal/dockerdeploy/controlled_session_watchdog_integration_linux_test.go Linux integration test validating process-group isolation and parent-loss cleanup in Docker.
internal/dockerdeploy/controlled_session_watchdog_integration_unsupported_test.go Non-Linux integration test placeholder asserting unsupported behavior.
internal/dockerdeploy/controlled_session_supervisor.go Supervisor now records ownership then starts watchdog before controller/workload, and disarms it after successful cleanup.
internal/dockerdeploy/controlled_session_supervisor_test.go Supervisor unit tests covering watchdog launch ordering, launch failure handling, and disarm gating/error paths.
internal/dockerdeploy/controlled_session_supervisor_integration_test.go Docker integration test builds a reploy binary for the watchdog child path and validates parent-loss cleanup.
docs/CONTROLLED_SESSION_DESIGN.md Update design doc to include watchdog lifecycle, readiness/disarm semantics, and cleanup guarantees.
cmd/reploy/main.go Entrypoint dispatch to handle watchdog child mode before normal CLI execution.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +158 to +166
removeErr := backend.removeContainer(ctx, container.ID)
_, stillFound, inspectErr := backend.inspectContainer(ctx, container.ID)
if inspectErr != nil {
return errors.Join(removeErr, fmt.Errorf("verify controlled-session %s container %q removal: %w", container.Role, container.ID, inspectErr))
}
if stillFound {
return errors.Join(removeErr, fmt.Errorf("controlled-session %s container %q still exists after removal", container.Role, container.ID))
}
return nil
Comment thread cmd/reploy/main.go
Comment on lines 10 to 14
func main() {
if code, handled := dockerdeploy.RunControlledSessionWatchdogChild(os.Args[1:], os.Stderr); handled {
os.Exit(code)
}
os.Exit(cli.Main(os.Args[1:], os.Stdout, os.Stderr))
Comment on lines +885 to +887
return status, controlledsession.CleanupStatusV1{
Kind: controlledsession.CleanupStatusFailedV1, Message: "controlled-session delivery-tail cleanup failed",
}, controlledsession.RecoveryRetryCleanupV1
@omry omry added the approved PR reviewed and approved label Aug 9, 2026 — with ChatGPT Codex Connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved PR reviewed and approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants