Skip to content

[release/2.4] ctr: fix flag parsing issues in run, containers create, tasks exec, and oci-hook - #14215

Merged
samuelkarp merged 2 commits into
containerd:release/2.4from
k8s-infra-cherrypick-robot:cherry-pick-14209-to-release/2.4
Sep 23, 2026
Merged

samuelkarp merged 2 commits into
containerd:release/2.4from
k8s-infra-cherrypick-robot:cherry-pick-14209-to-release/2.4

Conversation

@k8s-infra-cherrypick-robot

@k8s-infra-cherrypick-robot k8s-infra-cherrypick-robot commented Sep 23, 2026 •

Copy link
Copy Markdown

This is an automated cherry-pick of #14209

/assign samuelkarp

Fix bug where container command arguments were parsed as flags in "ctr run", "ctr containers create", "ctr tasks exec", and "containerd oci-hook"

urfave/cli/v3 scans for flags across all positional arguments by
default, which causes flags meant for the container process to be
parsed as ctr flags.

Configure StopOnNthArg to stop flag parsing before the container
command and its arguments:
- "ctr run" and "ctr containers create": after Image|RootFS and
  CONTAINER (2 args)
- "ctr tasks exec": after CONTAINER (1 arg)

Fixes containerd#14208

Assisted-by: Antigravity
Signed-off-by: Samuel Karp <[email protected]>
"containerd oci-hook" defines no flags of its own and passes all
arguments directly to the target hook binary via syscall.Exec. Set
StopOnNthArg to 1 so urfave/cli/v3 stops flag parsing after the hook
binary path while still stripping an optional "--" separator.

Assisted-by: Antigravity
Signed-off-by: Samuel Karp <[email protected]>
@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Sep 23, 2026

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thx!

@samuelkarp
samuelkarp merged commit 8949dc8 into containerd:release/2.4 Sep 23, 2026
97 of 98 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Sep 23, 2026
@samuelkarp samuelkarp added impact/changelog area/ctr ctr development tool labels Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants