Skip to content

volume create: detect --secret and --topology-* as cluster options - #7329

Open
fadiroot wants to merge 1 commit into
docker:masterfrom
fadiroot:fix-volume-create-cluster-flags
Open

fadiroot wants to merge 1 commit into
docker:masterfrom
fadiroot:fix-volume-create-cluster-flags

Conversation

@fadiroot

Copy link
Copy Markdown

Summary

hasClusterVolumeOptionSet decides whether a ClusterVolumeSpec is attached to the create request. It checked for a flag named secrets, but the flag is registered as secret, so flags.Changed("secrets") was always false. The --topology-required and --topology-preferred flags were not part of the check at all.

Running docker volume create with only one of those options, for example:

$ docker volume create -d my-csi-driver --secret key=val myvol
$ docker volume create -d my-csi-driver --topology-required region=R1 myvol

therefore created a plain, non-cluster volume and silently dropped the option.

This PR:

  • fixes the flag name in hasClusterVolumeOptionSet and adds the two topology flags to it
  • swaps the help text of --limit-bytes / --required-bytes, which were reversed: RequiredBytes is the minimum capacity and LimitBytes the maximum, per the volume.CapacityRange docs. The generated markdown table is updated to match
  • adds TestVolumeCreateClusterOptionDetection, which sets each cluster-only flag on its own and checks that the resulting ClusterVolumeSpec carries it. The new test fails for secret, topology-required and topology-preferred on master and passes with this change

Verify with:

$ go test ./cli/command/volume/ -run TestVolumeCreate -v

Release notes (optional)

- Fix `docker volume create` ignoring `--secret`, `--topology-required` and `--topology-preferred` when no other cluster-volume option is set.

@fadiroot
fadiroot requested review from a team and thaJeztah as code owners September 24, 2026 09:46
@vvoland
vvoland requested review from docker-agent and a balanced review from Copilot September 24, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new exhaustive regression test omits standalone coverage for three cluster-specific flags.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes cluster-volume option detection and corrects capacity help text.

Changes:

  • Detects secret and topology flags as cluster options.
  • Corrects minimum/maximum capacity descriptions.
  • Adds per-flag regression tests.
File Description
cli/​command/​volume/​create.go Fixes cluster detection and help text.
cli/​command/​volume/​create_test.go Adds option-detection tests.
docs/​reference/​commandline/​volume_create.md Updates generated capacity documentation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cli/command/volume/create_test.go Outdated
Availability: volume.AvailabilityDrain,
},
},
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch, thanks. Added standalone cases for --scope, --sharing and --type and an AccessMode assertion, so each of the three is now exercised on its own. I checked that misspelling any of them in hasClusterVolumeOptionSet makes exactly that subtest fail. Squashed into the same commit.

@fadiroot
fadiroot force-pushed the fix-volume-create-cluster-flags branch 2 times, most recently from cc669bb to 33452d8 Compare September 28, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants