Repository navigation
feat: Add --allow-rootless flag for rootless Podman support - #68
Conversation
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a persistent ChangesRootless support and provider updates
Sequence Diagram(s)sequenceDiagram
participant CLI as "minc CLI"
participant Marker as "rootlessmarker"
participant Register as "providers.Register"
participant PodmanProv as "podman provider instance"
participant Podman as "podman (sudo when needed)"
CLI->>Marker: Set() -- when --allow-rootless during create
CLI->>Register: Register(provider)
Register->>PodmanProv: New(allowRootless)
PodmanProv->>PodmanProv: storeGraphRoot(), populate COptions
PodmanProv->>PodmanProv: writeRootlessConfigs()
PodmanProv->>Podman: podman run / start container
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cmd/minc/config.go`:
- Line 27: The "allow-rootless" boolean is being written as a string by `config
set` and thus won't be recognized by `writeConfigWithoutDefaults()` as the
default false; update the code path that handles `config set` (the code that
stores raw args as strings) to detect boolean-like strings ("true"/"false") and
coerce them to actual bool types before persisting, or alternatively add a small
normalization step in `writeConfigWithoutDefaults()` to parse string values for
known boolean keys (e.g., "allow-rootless") back to bool; ensure the change
references the `allow-rootless` key and the `writeConfigWithoutDefaults()`
function so the stored JSON uses a real boolean rather than a string.
In `@cmd/minc/main.go`:
- Around line 114-115: The call to rootlessmarker.Remove() is currently ignoring
errors which can leave stale CLI state while still printing success; update the
delete path in main (where rootlessmarker.Remove() is called) to check the
returned error, and if non-nil print a clear error to stderr (e.g., via
fmt.Fprintf(os.Stderr,...)) and exit non-zero (os.Exit(1)) or return the error
from the command handler so the process reports failure; ensure you reference
and handle the error from rootlessmarker.Remove() and avoid printing "Item
deleted" on failure.
- Around line 60-76: The deferred rootlessmarker.Remove() is never reached
because log.Fatal exits immediately after minc.Create fails; change the error
path so the marker is cleaned up explicitly before exiting: after err :=
minc.Create(cType) if err != nil { if allowRL { _ = rootlessmarker.Remove() }
log.Fatal("error creating cluster", "err", err) } or alternatively replace
log.Fatal with a non-exiting log call and then ensure you call
rootlessmarker.Remove() before os.Exit; reference minc.Create,
rootlessmarker.Remove, allowRL and createFailed when making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 74c984c0-c2e4-4c57-9e5c-43793fc2ccaa
📒 Files selected for processing (8)
cmd/minc/config.gocmd/minc/main.gopkg/providers/moby/provider.gopkg/providers/options.gopkg/providers/podman/provider.gopkg/providers/register/register.gopkg/providers/wait.gopkg/rootlessmarker/marker.go
| "http-port": "9080", | ||
| "microshift-config": "", | ||
| "disable-overlay-cache": false, | ||
| "allow-rootless": false, |
There was a problem hiding this comment.
allow-rootless will not round-trip cleanly through config set.
config set stores raw args as strings, so minc config set allow-rootless false will be written as "false" and writeConfigWithoutDefaults() will never treat it as the default false bool. The new key will linger in the JSON with the wrong type.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@cmd/minc/config.go` at line 27, The "allow-rootless" boolean is being written
as a string by `config set` and thus won't be recognized by
`writeConfigWithoutDefaults()` as the default false; update the code path that
handles `config set` (the code that stores raw args as strings) to detect
boolean-like strings ("true"/"false") and coerce them to actual bool types
before persisting, or alternatively add a small normalization step in
`writeConfigWithoutDefaults()` to parse string values for known boolean keys
(e.g., "allow-rootless") back to bool; ensure the change references the
`allow-rootless` key and the `writeConfigWithoutDefaults()` function so the
stored JSON uses a real boolean rather than a string.
Hi @praveenkumar, thanks for the initial investigation on this issue. Your findings around The Regarding the CodeRabbit comment about I tested this on Fedora 43 / kernel 6.19 / rootless Podman with the |
|
Tip For best results, initiate chat on the files or code changes.
Noted on the ✏️ Learnings added
|
Add an "Allow rootless Podman" checkbox to the cluster creation form that passes --allow-rootless to the minc CLI. Change the Linux audit from a blocking error to an informational message when running as non-root, since rootless mode is now a supported configuration. Depends on minc-org/minc#68.
| // MicroShiftServiceMaxRetries bounds how long we poll systemctl is-active for the microshift | ||
| // unit inside the container. While the unit is "activating", is-active exits non-zero (often 3), | ||
| // so each poll is a retry. Rootless or slow storage can keep the unit activating for many minutes. | ||
| // With pkg/retry's delay = InitialDelay * attempt, 40 attempts implies ~26 minutes of backoff before failure. |
There was a problem hiding this comment.
how does this implies ~26 mins delay, to me it is 40 attempts with every 2 second delay which should be ~80 sec.
There was a problem hiding this comment.
how does this implies ~26 mins delay, to me it is 40 attempts with every 2 second delay which should be ~80 sec.
@praveenkumar, you're right that at first glance it looks like 80s, but pkg/retry/retry.go uses linear backoff (initialDelay * attempt), not constant delay. So attempt 1 sleeps 2s, attempt 2 sleeps 4s, ..., attempt 39 sleeps 78s. The total is 2 * sum(1..39) = 1560s ≈ 26 min. I'll update the comment to make the math clearer.
|
So I just testing this PR without going through the codebase and during my testing all the pods are not coming up, some issue around mount |
@praveenkumar, this is After that, |
Add an "Allow rootless Podman" checkbox to the cluster creation form that passes --allow-rootless to the minc CLI. Change the Linux audit from a blocking error to an informational message when running as non-root, since rootless mode is now a supported configuration. Depends on minc-org/minc#68. Signed-off-by: Alexon Oliveira <alolivei@redhat.com>
Hey @praveenkumar, just a follow-up on this: the companion PR on the extension side (minc-org/minc-extension#396) has been tested and approved by @danivilla9. During testing, he also initially hit the same port binding error ( The chown error you encountered is the same scenario, problem #5 in the PR description. It requires expanding the subordinate UID/GID ranges on the host (Step 4 in "Host Prerequisites") so that OpenShift SCC UIDs (~1000100000) fall within the mapped range: Could you give it another try with all four host prerequisites applied? Happy to help troubleshoot if anything else comes up. |
* feat: add rootless Podman support for Linux Add an "Allow rootless Podman" checkbox to the cluster creation form that passes --allow-rootless to the minc CLI. Change the Linux audit from a blocking error to an informational message when running as non-root, since rootless mode is now a supported configuration. Depends on minc-org/minc#68. Signed-off-by: Alexon Oliveira <alolivei@redhat.com> * fix: reword audit message to conditional phrasing The audit info message now instructs the user to enable the toggle rather than asserting the cluster will be created in rootless mode, since the audit runs independently of the form parameters. Signed-off-by: Alexon Oliveira <alolivei@redhat.com> --------- Signed-off-by: Alexon Oliveira <alolivei@redhat.com>
| // With pkg/retry's delay = InitialDelay * attempt, 40 attempts implies ~26 minutes of backoff before failure. | ||
| // | ||
| // pkg/retry uses linear backoff: sleep = InitialDelay * attempt. | ||
| // Total wait = InitialDelay * (1+2+...+(N-1)) = 2s * (39*40/2) = 1560s ≈ 26 min. |
There was a problem hiding this comment.
@AlexonOliveiraRH do we really need user to wait for 26 mins until backoff? For minc scenario user expect it to be faster so may be we should reduce the Max retry and set something which can only provide wait time around 5 mins (which is still not good but better than waiting for 26 mins, in which case user think it stuck and might be manually exit from minc process.
There was a problem hiding this comment.
@AlexonOliveiraRH do we really need user to wait for 26 mins until backoff? For minc scenario user expect it to be faster so may be we should reduce the Max retry and set something which can only provide wait time around 5 mins (which is still not good but better than waiting for 26 mins, in which case user think it stuck and might be manually exit from minc process.
@praveenkumar Good point. As per our conversation, I reduced the MicroShiftServiceMaxRetries from 40 to 18 in f86838b, with linear backoff that brings the total wait from ~26 min down to ~5 min (2s * (17*18/2) = 306s). Should be enough for slow rootless starts without leaving users wondering if it's stuck.
|
@AlexonOliveiraRH description on this PR which talk about one time host configuration should be part of README or a separate doc if user want to try rootless. |
f86838b to
c495f71
Compare
@praveenkumar done. Could you check it again, please? Thank you. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/minc/main.go`:
- Around line 68-70: When a create error occurs and allowRL is true, currently
rootlessmarker.Remove() is ignored; change this so you capture and handle its
returned error: after calling rootlessmarker.Remove() from the create-error
path, check its error value and surface it (log it and/or wrap it into the
returned error) so callers see that cleanup failed and stale rootless state may
remain; update the create failure handling to include the
rootlessmarker.Remove() error (e.g., append or wrap) and ensure you still return
the original create error context.
In `@README.md`:
- Around line 121-159: The README currently states "All steps require root/sudo"
but then instructs to run "podman system migrate" in step 4; this must be run in
the target user's rootless context (not as root) to migrate the correct Podman
state. Update the docs so step 4 explicitly instructs running podman system
migrate as the target user (for example by showing it executed as that user) or
change the "All steps require root/sudo" note so it excludes the podman system
migrate step; ensure the text references the exact command name "podman system
migrate" and clarifies it must not be run as root.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7b4f8fb1-8064-4f88-a1f7-578bf219ff2e
📒 Files selected for processing (9)
README.mdcmd/minc/config.gocmd/minc/main.gopkg/providers/moby/provider.gopkg/providers/options.gopkg/providers/podman/provider.gopkg/providers/register/register.gopkg/providers/wait.gopkg/rootlessmarker/marker.go
🚧 Files skipped from review as they are similar to previous changes (4)
- pkg/providers/wait.go
- pkg/rootlessmarker/marker.go
- pkg/providers/options.go
- pkg/providers/podman/provider.go
c495f71 to
d7c2003
Compare
|
We should also have a GH action workflow to make sure that rootless works in linux as expected. |
d7c2003 to
98c2e15
Compare
@praveenkumar done too. I used your |
|
@AlexonOliveiraRH CI failure for rootless mode, may be try locally on ubuntu system and check if there is something different for fedora and ubuntu side. |
Add rootless Podman support to minc, enabling cluster creation without sudo via a new --allow-rootless flag. Eight distinct issues were discovered and resolved during rootless bringup, including CRI-O cgroup manager failures, IPv6 localhost resolution, oom_score_adj EPERM in user namespaces, and high-UID chown failures from OpenShift SCCs. Key changes: - New --allow-rootless persistent flag with rootless marker file - Rootless config generation (MicroShift YAML, CRI-O drop-in, crun wrapper) - Provider refactor from global state to instance fields - Shared retry constants for MicroShift service polling (~5 min timeout) - Host prerequisites documentation in README Fixes minc-org#22 Signed-off-by: Alexon Oliveira <alolivei@redhat.com>
98c2e15 to
165aa2f
Compare
@praveenkumar, the CI failure was caused by overlapping subordinate UID ranges. I verified on a testing machine that on Ubuntu runners, the default |
|
Any plan to have a new release with this? |
@AkihiroSuda, what a privilege to have someone like you showing interest in a PR of mine! :) @praveenkumar is the maintainer, but I can see that the v0.2.0 release was published on September 9th and includes the You can try it with:
The release changelog confirms it: v0.1.0...v0.2.0 Cheers |
Summary
This PR adds rootless Podman support to minc, enabling
minc createwithoutsudoor root privileges via a new--allow-rootlessflag. It resolves all blockers identified in #22.With all changes applied, all MicroShift system pods reach
Runningstatus under rootless Podman on Fedora 43 / kernel 6.19 / crun 1.23.Problems Solved
Eight distinct issues were discovered and resolved during rootless bringup:
Failed to connect to bus: No medium found) - no D-Bus user session in rootless20-rootless.conf) switching tocgroupfs, overriding10-microshift.conf--sysctl net.ipv6.conf.all.disable_ipv6=1at container creationoom_score_adjwrites fail with EPERM in user namespacescrun-rootlesswrapper stripsoomScoreAdjfrom OCI spec viajqcpusetcgroup controller not delegated to user sessionschownfails with EINVAL for high OpenShift SCC UIDscrio-subid.servicefailure inside container/dev/kmsgnot accessible in rootless namespaces/dev/nullas/dev/kmsgKubeletInUserNamespacefeature gate via MicroShift config drop-inCode Changes
cmd/minc/main.go--allow-rootlesspersistent flag, rootless marker lifecyclecmd/minc/config.goallow-rootlessin default configpkg/providers/podman/provider.gopkg/providers/options.gopkg/providers/moby/provider.gopkg/providers/register/register.goallowRootlessto provider constructorpkg/providers/wait.gopkg/rootlessmarker/marker.go~/.config/minc/.rootless-clusterKey design decisions
createanddeleteso subsequent commands (delete, generate-kubeconfig) work without re-specifying--allow-rootless.useSudovariable andsync.Oncewith instance fields on the provider struct, eliminating shared mutable state.Store.GraphRoot) instead of hardcoding/var/lib/containers/storage, which differs in rootless mode.~/.config/minc/and bind-mounted into the container at creation time.20-prefix ensures rootless configs override MicroShift's10-microshift.conf.Host Prerequisites (One-Time Setup)
Four host-side changes are required before using
--allow-rootless. Steps 1-3 require root/sudo. All settings persist across reboots.1. Kernel parameters (sysctl):
ip_forward- required for container networking (packet forwarding)ip_unprivileged_port_start = 80- allows rootless Podman to bind HTTP/HTTPS ports (80, 443)max_user_instances = 1024- increases inotify watch limit for MicroShift services2. Load
ip_tableskernel module:3. Delegate cpuset cgroup controller:
4. Expand subordinate UID/GID ranges (for OpenShift SCC high UIDs):
sudo usermod --add-subuids 165536-1265535999 --add-subgids 165536-1265535999 $(whoami)Then, as your regular user (not root), migrate Podman to pick up the new ranges:
Usage
Test Environment
Test Results
All 9 MicroShift system pods reach
Runningstatus under rootless Podman:Future Work
--rootlessflag fixingoom_score_adj)References
Fixes #22
Summary by CodeRabbit
New Features
Improvements
Documentation