fix(operator): mount configMap keys as subPaths to preserve image defaults#267
Conversation
…aults A package's configMap was mounted as a single directory volume at /skyhook-package/configmaps, which (per standard Kubernetes ConfigMap-as-volume behavior) replaced the entire directory and hid any files the package image baked in at that path. Package authors could not ship default files and let users override individual keys. Mount each configMap key as its own subPath instead, so user-supplied files overlay on top of image content rather than replacing the whole directory; image-side files for keys the user did not supply remain visible. Keys are iterated in sorted order for a deterministic pod spec. subPath mounts do not receive live configMap updates, but package pods are recreated per stage / version bump and never observed live edits in practice. Closes #208 Signed-off-by: Brian Lockwood <lockwobr@gmail.com>
|
Lost in the diff? Review this PR in Change Stack to follow the change map from intent to exact ranges. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR refactors ConfigMap volume mounting in package pod generation. Previously, mounting a ConfigMap as a directory volume at Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Coverage Report for CI Build 27040174901Warning No base build found for commit Coverage: 81.63%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
Summary
Fixes #208.
A package's
configMapwas mounted as a single directory volume at/skyhook-package/configmaps. Per standard Kubernetes ConfigMap-as-volume behavior, a directory mount replaces the entire directory, hiding any files the package image baked in at that path. This forced an all-or-nothing choice on package authors: ship a complete config via the SCR, or accept whatever the image provides; you could not ship sensible defaults in the image and let users override individual files.This change mounts each ConfigMap key as its own
subPath(MountPath: /skyhook-package/configmaps/<key>,SubPath: <key>,ReadOnly: true). The underlying volume is still mounted once; only the specific keys the user supplies overlay on top of the image content, so image-side files for un-supplied keys remain visible. Keys are iterated in sorted order so the generated pod spec is deterministic.Behavior change
A; user supplies{B}B(whole dir replaced)A(image) +B(configMap){A, B}A,Bfrom configMap{A}AA(unchanged)The last row is the only regression, and it was never actually exercised: package pods are short-lived and recreated by the operator on version bump / generation change, so they never observed live ConfigMap edits.
Tests
operator/internal/controller/skyhook_controller_test.goverifying per-key subPath mounts, sorted order, read-only, no bare directory mount, and a single backing volume. Written test-first (RED → GREEN).go vetandgolangci-lintclean.explicit-uninstallchainsaw e2e, which asserted the old directorymountPath, to assert the new per-key subPath mounts. (Chainsaw run pending a cluster; static assertions match the verified pod spec.)Docs
/skyhook-package/configmaps.