Skip to content

Add V2 container and process lifecycle monitors - #266

Merged
David Negstad (danegsta) merged 8 commits into
mainfrom
danegsta-v2-resource-crash-monitors
Sep 18, 2026
Merged

David Negstad (danegsta) merged 8 commits into
mainfrom
danegsta-v2-resource-crash-monitors

Conversation

@danegsta

@danegsta David Negstad (danegsta) commented Sep 17, 2026

Copy link
Copy Markdown
Member

V2-created containers and processes need runtime cleanup when DCP exits unexpectedly, while retained resources need explicit lifecycle ownership. This adds lifecycle monitors for those active resources and makes created volumes retained by default, with controller-managed deletion as an explicit opt-in.

Summary

  • Launch best-effort lifecycle monitors for created V2 containers and processes when their runtime object is configured to be removed or stopped with the Kubernetes resource.
  • Allow retained containers and processes to monitor a configured PID and identity timestamp. Retained containers use stop-only cleanup so the runtime object is preserved.
  • Preserve normal controller-managed deletion for networks and opt-in removable volumes. Networks and volumes do not launch dedicated crash monitors; abandoned resources remain eligible for workload-scoped cleanup.
  • Replace retainRuntimeVolume with removeRuntimeVolumeOnDelete. Created volumes are now retained by default; setting the new flag opts into non-forced controller deletion. Namespace cleanup bounds in-use volume removal retries to 30 seconds.
  • Forward the selected container runtime to container monitor subprocesses so cleanup targets the same runtime as the controller.
  • Update generated API artifacts, controller and integration coverage, and the V2 resource roadmap.

Validation

  • make test
  • make lint

Add lifecycle monitors for V2 containers, processes, networks, and removable volumes. Support explicit monitor targets for retained containers and processes, retain volumes by default, and bound in-use volume cleanup retries.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Monitor cancellation races, retained-container startup ordering, and stale volume-name ownership can prevent cleanup or remove replacement resources.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds crash-monitor processes for V2 physical resources and makes created volumes retained by default.

Changes:

  • Adds lifecycle monitors for containers, processes, networks, and removable volumes.
  • Adds retained-resource monitor PID/timestamp configuration.
  • Updates volume cleanup policy, generated APIs, documentation, and tests.
File summaries
File Description
api/v2/common_types.go Validates monitor identity fields.
api/v2/physical_container_types.go Adds retained-container monitoring fields.
api/v2/physical_container_types_test.go Tests container monitor validation.
api/v2/physical_process_types.go Adds retained-process monitoring fields.
api/v2/physical_process_types_test.go Tests process monitor validation.
api/v2/physical_container_volume_types.go Reverses the volume cleanup default.
api/v2/physical_container_volume_types_test.go Updates volume immutability coverage.
api/v2/zz_generated.deepcopy.go Regenerates deep-copy methods.
controllers/physical_container_controller.go Launches retained-container monitors.
controllers/physical_process_controller.go Launches configurable process monitors.
controllers/physical_container_network_controller.go Launches network cleanup monitors.
controllers/physical_container_volume_controller.go Applies opt-in cleanup and monitoring.
controllers/physical_resource_invalid_state_test.go Updates volume retention assumptions.
internal/dcpctrl/commands/run_controllers.go Supplies process executors to controllers.
internal/dcpproc/dcpproc_api.go Adds network and volume watcher launchers.
internal/dcpproc/dcpproc_api_test.go Tests watcher command construction.
internal/dcpproc/commands/network.go Implements network cleanup monitoring.
internal/dcpproc/commands/volume.go Implements bounded volume cleanup monitoring.
internal/dcpproc/commands/root.go Registers new monitor commands.
internal/dcpproc/commands/container_resource_test.go Tests network and volume cleanup behavior.
pkg/generated/openapi/zz_generated.openapi.go Regenerates V2 OpenAPI schemas.
plan/v2-resource-plan.md Documents lifecycle policy and roadmap.
test/integration/advanced_test_env.go Updates advanced controller construction.
test/integration/standard_test_env.go Enables monitors in standard tests.
test/integration/v2_physical_container_controller_test.go Covers retained-container monitoring.
test/integration/v2_physical_container_network_controller_test.go Covers network monitor launching.
test/integration/v2_physical_container_network_durability_test.go Updates network reconciler construction.
test/integration/v2_physical_container_volume_controller_test.go Covers volume retention and monitoring.
test/integration/v2_physical_container_volume_durability_test.go Updates removable-volume durability tests.
test/integration/v2_physical_process_controller_test.go Covers retained-process monitoring.
Review details

Files not reviewed (1)

  • api/v2/zz_generated.deepcopy.go: Generated file
  • Files reviewed: 28/30 changed files
  • Comments generated: 5
  • Review effort level: Balanced

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

Comment thread internal/dcpproc/commands/volume.go Outdated
Comment thread controllers/physical_container_controller.go
Comment thread controllers/physical_container_controller.go
Comment thread internal/dcpproc/commands/network.go Outdated
Comment thread internal/dcpproc/commands/volume.go Outdated
Make resource-removal polling cancellation-safe, start retained container monitors only after successful startup, and protect volume cleanup against same-name replacement using the physical resource UID.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore the V1 container controller's private UID label declaration so the V2 volume monitor ownership fix does not create an unrelated V1 source change.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace the custom container-resource polling loop with the shared resiliency retry helper and a jittered constant-interval backoff.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove dedicated network and volume crash monitors while preserving normal controller deletion and retained-by-default volumes. Forward the selected container runtime through the existing container monitor API.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore the pre-existing pollContainerRemoved behavior and remove the shared polling abstraction that is no longer needed after dropping network and volume crash monitors.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The stated network and volume monitor scope does not match the implementation or updated roadmap.

Get a fresh assessment by requesting another Copilot review.

Review details

Files not reviewed (1)

  • api/v2/zz_generated.deepcopy.go: Generated file
  • Files reviewed: 19/21 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread plan/v2-resource-plan.md
@danegsta David Negstad (danegsta) changed the title Add crash monitors for V2 physical resources Add V2 container and process lifecycle monitors Sep 18, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Public API, controller lifecycle, and subprocess cleanup changes warrant final human validation despite comprehensive coverage.

Review details

Files not reviewed (1)

  • api/v2/zz_generated.deepcopy.go: Generated file
  • Files reviewed: 22/24 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@danegsta
David Negstad (danegsta) merged commit 73c492a into main Sep 18, 2026
13 checks passed
@danegsta
David Negstad (danegsta) deleted the danegsta-v2-resource-crash-monitors branch September 18, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants