Repository navigation
ctr: fix flag parsing issues in run, containers create, tasks exec, and oci-hook - #14209
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Critical compile errors and an OCI hook separator-handling issue remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 4
Open (4)
What changed in this PR
Fixes flag parsing for ctr commands and containerd oci-hook, preserving dash-prefixed positional arguments.
Changes:
- Stops flag parsing after required positional arguments.
- Disables flag parsing for OCI hook arguments.
- Adds regression tests for argument passthrough.
| File | Summary | Review |
|---|---|---|
cmd/ctr/commands/tasks/exec.go |
Preserves arguments after the container ID. | Critical (1 vote): new(1) is a compile-time error. |
cmd/ctr/commands/tasks/exec_test.go |
Tests exec arguments containing flags. | No findings. |
cmd/ctr/commands/run/run.go |
Preserves run command arguments. | Critical (1 vote): new(2) is a compile-time error. |
cmd/ctr/commands/run/run_test.go |
Tests run arguments containing flags. | No findings. |
cmd/ctr/commands/containers/containers.go |
Preserves create command arguments. | Critical (1 vote): new(2) is a compile-time error. |
cmd/ctr/commands/containers/containers_test.go |
Tests create arguments containing flags. | No findings. |
cmd/containerd/command/oci-hook.go |
Preserves OCI hook arguments. | Critical (3 votes): The -- separator remains in cmd.Args() and may be executed as the hook. |
cmd/containerd/command/oci-hook_test.go |
Tests OCI hook argument passthrough. | No findings. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
koriyoshi2041
left a comment
There was a problem hiding this comment.
The completed integration matrix now reproduces a causal regression in every Linux/VM job: TestContainerHook invokes containerd oci-hook -- <hook> ..., but SkipFlagParsing preserves the separator in c.Args(), so the action attempts to execute -- instead of the hook. The representative failure is error running createRuntime hook #0 ... stderr: containerd: no such file or directory in job 107009687969; all 199 integration tests pass except this test.
Could the command preserve dash-prefixed hook arguments while still consuming the CLI separator, and add the existing production-shaped oci-hook -- <path> --pid ... form as a regression? The current unit test covers only the no-separator invocation, so it cannot detect this path.
|
Please don't have your LLM pretend to be a maintainer. |
|
You're right — using |
|
Our contributing guidelines state that this behavior is unacceptable:
|
|
Failure could be legit; looks like it's failing across the board; |
|
@thaJeztah Yeah, the failure is legit. I'm looking at it this morning. |
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]>
d829b1e to
0250b93
Compare
LLM, not human review comments
|
/cherry-pick release/2.4 |
|
@samuelkarp: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@samuelkarp: new pull request created: #14215 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |

Fixes #14208