feat: per-namespace overlay isolation#24
Merged
miguelgila merged 12 commits intomainfrom Feb 28, 2026
Merged
Conversation
… isolation Add `namespace: Option<String>` to ContainerState with serde defaults for backward compatibility. Old state files without the field deserialize to None. Includes round-trip and backward-compat tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduce OverlayIsolation::Namespace (default) and OverlayIsolation::Node modes. read_config() now takes Option<&str> for K8s namespace: - Namespace mode: scoped paths under /run/reaper/overlay/<ns>/, etc. - Node mode: legacy flat layout, ignores namespace arg Add merged_dir to OverlayConfig (was hardcoded). Add namespace path validation. Update do_start() and do_exec() callers. Comprehensive tests for isolation mode, per-NS paths, and validation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Thread the K8s namespace from CLI through do_create() into ContainerState. do_start() and do_exec() read it back from state to pass to overlay::read_config() for per-namespace isolation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…espace Shim reads io.kubernetes.pod.namespace from config.json annotations and passes --namespace <ns> to reaper-runtime create. This enables the runtime to scope overlay paths per K8s namespace. Includes tests for present/missing/absent annotations and missing config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tegration tests Existing integration tests use node-wide shared overlay. With the new default of per-namespace isolation, they need explicit node mode to continue working without --namespace. Also gate container_namespace variables with #[cfg(target_os = "linux")] to avoid unused-variable warnings on macOS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New test file covering: - Namespace mode without --namespace fails hard (refuses to start) - Node mode backward compat (different namespaces share overlay) - Helper supports both isolation modes and --namespace arg Tests require Linux root + CAP_SYS_ADMIN; skipped gracefully elsewhere. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update CLAUDE.md with new path layout, REAPER_OVERLAY_ISOLATION config. Add Namespace Isolation section to OVERLAY_DESIGN.md with data flow, path layout, legacy mode, and upgrade path. Mark TODO item as done. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
containerd CRI writes `io.kubernetes.cri.sandbox-namespace` not `io.kubernetes.pod.namespace`. Try the CRI key first with fallback to the pod key for compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deploys a writer pod in the default namespace and a reader pod in a separate namespace, then verifies the reader cannot see the writer's overlay files — confirming overlays are isolated per K8s namespace. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Allow up to 1% project coverage decrease without failing the check. Require 70% coverage on new code (patch). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests calling unwrap_err() require Debug on the Ok type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24 +/- ##
==========================================
+ Coverage 85.94% 88.26% +2.31%
==========================================
Files 5 5
Lines 185 213 +28
==========================================
+ Hits 159 188 +29
+ Misses 26 25 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
io.kubernetes.cri.sandbox-namespace(with fallback toio.kubernetes.pod.namespace) from OCI annotations and passes--namespaceto the runtime/run/reaper/overlay/<ns>/REAPER_OVERLAY_ISOLATION=nodeto use the legacy shared overlayChanges
OverlayIsolationenum, parameterizedread_config()with per-namespace pathsnamespacefield inContainerStatefor start/exec to join correct overlay--namespaceCLI arg oncreate, threaded through start/execextract_k8s_namespace()reads CRI annotation, passes--namespaceto runtimeTest plan
cargo test --bin containerd-shim-reaper-v2— all 37 unit tests passcargo test --test integration_overlay_isolation— Rust integration tests (Linux+root)./scripts/run-integration-tests.sh --verbose— all 30 Phase 4 tests pass, including new "Per-namespace overlay isolation" testREAPER_OVERLAY_ISOLATION=nodeto preserve behavior🤖 Generated with Claude Code