summaryrefslogtreecommitdiff
path: root/internal/cli
diff options
context:
space:
mode:
authorJames O'Doherty <james@theodohertyfamily.com>2026-05-29 20:35:31 -0400
committerJames O'Doherty <james@theodohertyfamily.com>2026-05-29 20:35:31 -0400
commitd4cec92f5690a60b3509ab718bdea72dc520110e (patch)
treeb29218a4fee4bbf3b2f4bf25a161f2a74bb98b85 /internal/cli
parent4ddd0d2ffc7073f2d55ffb6777e3a168af0051f0 (diff)
feat: implement robust namespace lifecycle and resilience suite
- Replace marker-file pinning with kernel bind-mount anchors for reliable namespace persistence. - Implement atomic "last-man-out" cleanup sequence using ProfileLock, preventing namespace leaks and race conditions. - Add comprehensive resilience test suite covering: - Crash recovery from stale runtime state. - Host network change stability. - Configuration hot-swap session persistence. - Resource exhaustion and high-churn lifecycle stress. - Align documentation and test expectations with rootless session-based persistence. - Fix argument integrity and isolation leaks. - Ensure 100% pass rate for all E2E and integration tests.
Diffstat (limited to 'internal/cli')
-rw-r--r--internal/cli/cli.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/internal/cli/cli.go b/internal/cli/cli.go
index 87ee34f..076d46b 100644
--- a/internal/cli/cli.go
+++ b/internal/cli/cli.go
@@ -179,13 +179,18 @@ func (a *App) ExecuteCommand(cfg *config.Config) error {
// Re-acquire lock for the entire cleanup sequence to ensure atomic unregister and unpin
cleanupLock, cleanupErr := namespace.AcquireProfileLock(pm, cfg.Profile)
if cleanupErr == nil {
- // Check if we are the last active process before unregistering
- last, lastErr := namespace.IsLastProcess(pm, cfg.Profile)
-
+ // 1. Unregister the process first.
if err := namespace.UnregisterProcess(pm, cfg.Profile); err != nil {
fmt.Printf("failed to unregister process: %v\n", err)
}
+ // 2. Prune and check if we are the last process.
+ if err := namespace.PruneStalePids(pm, cfg.Profile); err != nil {
+ fmt.Printf("failed to prune stale pids during cleanup: %v\n", err)
+ }
+
+ last, lastErr := namespace.IsLastProcess(pm, cfg.Profile)
+
if lastErr == nil && last {
fmt.Printf("Last process exiting. Cleaning up profile %s...\n", cfg.Profile)
if err := namespace.UnpinNamespace(pm, cfg.Profile); err != nil {