Skip to content

ctr: Subcommands split slice flags (e.g. --mount) on commas after migration to urfave/cli/v3 #14181

Closed

Description

@chenglongtang1

Background:

Description

In containerd 2.4.0, cmd/ctr was migrated to urfave/cli/v3. While DisableSliceFlagSeparator: true is set on the root ctr command (cmd/ctr/app/main.go), child subcommands (containers create, run, etc.) do not inherit this flag in urfave/cli/v3.

As a result, slice flags containing commas (such as --mount type=bind,src=/path,dst=/path,options=rbind:ro) are erroneously split on commas into separate slice elements with empty destinations, causing container task initialization to fail during runc mount setup:

ctr: failed to create shim task: OCI runtime create failed: runc create failed:
unable to start container process: error during container init:
error mounting "" to rootfs at "": create mountpoint for mount:
mountpoint "/run/containerd/io.containerd.runtime.v2.task/default/test/rootfs" is on the top of rootfs "/run/containerd/io.containerd.runtime.v2.task/default/test/rootfs"

This regression impacts node workflows, diagnostics, autotests, and GKE Installables.

Steps to Reproduce

Run any ctr command passing a --mount flag with comma-separated options:

ctr containers create \
  --mount type=bind,src=/var/lib/containerd/binary,dst=/binary,options=bind \
  <image> test
ctr task start -d test

Inspecting the container spec (ctr containers info test) shows the single --mount flag was split into 4 separate mounts:

"mounts": [
    {"destination": "", "type": "bind"},
    {"destination": "", "source": "/var/lib/containerd/binary"},
    {"destination": "/binary"},
    {"destination": "", "options": ["bind"]}
]

Root Cause

In urfave/cli/v3 (flag_slice_base.go and command.go):

  • Multi-value slice flags split on commas by default unless cmd.DisableSliceFlagSeparator == true.
  • When subcommands execute, setMultiValueParsingConfig checks cmd.DisableSliceFlagSeparator on the active subcommand cmd.
  • Unlike useShortOptionHandling(), urfave/cli/v3 does not traverse cmd.Lineage() for DisableSliceFlagSeparator (see also urfave/cli#1856).
  • Because ctr only sets DisableSliceFlagSeparator: true on the root command, all subcommands execute with DisableSliceFlagSeparator: false.

Proposed Fix

Explicitly set DisableSliceFlagSeparator: true on all subcommands where slice flags are accepted, or traverse command definitions when constructing ctr commands.

Activity

  1. added theissue type on Sep 17, 2026
  2. added
    status/accepted
    area/ctr
    on Sep 17, 2026
  3. added a commit that references this issue on Sep 17, 2026
    ef85c8f
  4. added a commit that references this issue on Sep 17, 2026
    2543d23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ctrkind/bugstatus/accepted

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions