Repository navigation
fix: run nf-spawn's docker run via sudo, fixing exit-126 socket permission (#92) - #94
Merged
Merged
Conversation
…ssion (#92) Every containerized process failed exit 126 with "permission denied" on /var/run/docker.sock. nf-spawn's ensureDocker step installs Docker but never puts the task user in the docker group (and a mid-session usermod wouldn't take effect anyway, since setup and the task run in one continuous shell). Prefix the docker run invocation with sudo instead — the task user already has passwordless sudo (relied on by ensureDocker's own dnf/systemctl calls), and this matches spawn's own task wrapper, which runs its docker calls the same way. Fixes #92.
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
Fixes #92 — every containerized process (
containerdirective +executor = 'spawn') on a stock AMI failed immediately with exit 126 and this in.command.err:docker run(inSpawnTaskHandler.buildRunLine,src/main/groovy/io/nextflow/spawn/SpawnTaskHandler.groovy) — not Nextflow's own container-launch code, since thedocker runnever appears in.command.run, anddocker { sudo = true }(which would only affect Nextflow's own docker calls) had no effect.ensureDocker's setup script (buildSetupScript) installs Docker and starts the daemon, but never puts the task user in thedockergroup — and even if it tried to (usermod -aG docker), that wouldn't take effect in the same shell session, which is exactly what happens here: setup and the containerized task run in one continuousbash -lcinvocation (no new login shell in between).docker runinvocation withsudo. This is the option the issue itself suggested and the one confirmed safe by checking the actual instance provisioning: spawn's own bootstrap grants the launched instance's login user passwordless sudo (NOPASSWD:ALLin/etc/sudoers.d/, inspawn'spkg/launcher/bootstrap.go) — the very same precondition nf-spawn's staging script already depends on for itssudo dnf install/sudo systemctl/sudo mkdircalls.sudoalso matches how spawn's own task wrapper (pkg/taskproto/wrapper.go,writeContainerRun) runs its own docker invocations, for the identical reason ("AL2023's default user has passwordless sudo").newgrpto take effect, which doesn't fit nf-spawn's single-continuous-session execution model — sudo is simpler and matches an assumption already relied on elsewhere in this file.Changes
SpawnTaskHandler.buildRunLinenow emitssudo docker run --rm ...instead ofdocker run --rm .... No change to the bare-OS (nocontainerdirective) path.sudo. Verified this test fails against pre-fix code and passes after (manually reverted the one-line fix, re-ran, saw only the new test fail; restored and re-ran, saw all 97 tests pass).CHANGELOG.md—## [Unreleased]entry underFixed, referencing Containerized processes fail exit 126: nf-spawn's docker run can't reach the Docker socket (task user not in docker group) #92.Secondary observation (instance lifecycle lingering)
The issue also reported a failed task's instance not promptly terminating, and a completed task's instance lingering ~1-2 min post-completion. Investigated by reading
spawn'spkg/agent/agent.goandpkg/taskproto/wrapper.go:spored's lifecycle ticker (Agent.Monitor) that driveson_completedefaults to a 1-minute period, so a completion signal can wait up to ~1 tick before being acted on.running(not just laggy) is NOT clearly explained by reading the code:spawn task run's wrapper unconditionally writes the completion record and/tmp/SPAWN_COMPLETEregardless of the task's exit code, so a failed task should self-terminate on the same ~1-2 min bound as a successful one. This needs a live re-run to confirm or refute (and may not even reproduce now that this docker-socket bug — which was making every task fail — is fixed). Rather than guess, I filed a separate issue: Investigate: failed-task instance reported still running past on_complete terminate (#92 secondary observation) #93.Test plan
./gradlew test— 97/97 tests pass (was 96 before this PR; added 1)./gradlew check— clean