Skip to content

Align wslc volume inspect and prune output with docker - #41404

Open
ggarzia-MSFT wants to merge 2 commits into
masterfrom
user/ggarzia/volume-output-parity
Open

Align wslc volume inspect and prune output with docker#41404
ggarzia-MSFT wants to merge 2 commits into
masterfrom
user/ggarzia/volume-output-parity

Conversation

@ggarzia-MSFT

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Brings wslc volume inspect and wslc volume prune output in line with the equivalent docker commands, continuing the CLI output parity work started for the network commands.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

volume inspect

The inspect payload was missing fields that docker always reports, and rendered absent maps as empty objects rather than null.

  • Added Mountpoint, sourced from the mountpoint docker reports for the volume, and plumbed through both the guest and VHD volume implementations on their create and open paths.
  • Added Scope, which is always local — every WSLC volume is machine level. The constant lives alongside the existing driver-name constants in WSLCVolumeMetadata.h.
  • Labels and Options are now std::optional and serialize as null when absent instead of {}.
  • Status is omitted entirely when the driver reports nothing. VHD volumes continue to populate it with HostPath, SizeBytes and, on a recovery failure, Error.
  • Renamed DriverOpts to Options on the read path. These are the same data under a read/write naming split — DriverOpts is the create-request spelling and remains unchanged, Options is the inspect spelling.

InspectVolume now uses an explicit to_json rather than the nlohmann macro, following the existing IPAMConfig convention in the same header, since the null-vs-empty and omit-when-empty behaviour cannot be expressed through the macro.

volume prune

  • Deleted volumes are now printed under a Deleted Volumes: header as bare names, replacing the per-line Deleted: <name> form. This matches the header already used by network prune.
  • The blank line before the reclaimed-space total is only written when something was actually deleted. It was previously emitted unconditionally, so a no-op prune produced a stray leading blank line.
  • Reclaimed space is now reported with four significant digits (12.29kB) rather than a two-decimal-place value with a space (12.29 KB).

WSLCCLI_VolumePruneDeleted is replaced by WSLCCLI_VolumePruneDeletedHeader; only the en-US resources are touched.

FormatDockerSize

Renamed to FormatHumanReadableSize and given a Precision parameter defaulting to 3. Image sizes keep precision 3; the prune reclaimed-space total uses 4. The only other caller, ImageTasks.cpp, is unaffected behaviourally.

Validation Steps Performed

  • Full cmake --build . completes with no errors.
  • Added WSLCE2E_Volume_Inspect_ReportsFullFieldSet, asserting the exact seven-key inspect payload, that Labels and Options are null, that Scope is local, that Mountpoint is non-empty, and that Status is absent.
  • Added FormatHumanReadableSize_SupportsReclaimedSpacePrecision covering the precision-4 cases, and renamed the existing precision-3 test.
  • Updated the volume prune e2e tests for the new header, bare names, and conditional blank line, including an exact-output assertion that a prune with nothing to delete emits only the reclaimed-space line.
  • Updated WSLCTests.cpp volume inspect coverage for Options, Scope and Mountpoint, and the volume-create and container-remove e2e tests for the optional Labels.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 20, 2026 22:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Aligns wslc volume inspect and volume prune output with Docker conventions.

Changes:

  • Adds Docker-compatible inspect fields and serialization behavior.
  • Updates prune formatting, spacing, headers, and size precision.
  • Renames and parameterizes human-readable size formatting.
  • Expands unit and end-to-end test coverage.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Summary Final review
test/windows/WSLCTests.cpp Updates volume inspect assertions. No final comments.
test/windows/wslc/e2e/WSLCE2EVolumePruneTests.cpp Verifies updated prune output and spacing. No final comments.
test/windows/wslc/e2e/WSLCE2EVolumeInspectTests.cpp Adds full inspect payload coverage. No final comments.
test/windows/wslc/e2e/WSLCE2EVolumeCreateTests.cpp Handles optional labels. No final comments.
test/windows/wslc/e2e/WSLCE2EContainerRemoveTests.cpp Handles optional volume labels. No final comments.
test/windows/StringUnitTests.cpp Tests formatter precision behavior. No final comments.
src/windows/wslcsession/WSLCVolumeMetadata.h Defines local volume scope. No final comments.
src/windows/wslcsession/WSLCVhdVolume.h Supports VHD volume mountpoints. No final comments.
src/windows/wslcsession/WSLCVhdVolume.cpp Plumbs VHD mountpoints and inspect fields. No final comments.
src/windows/wslcsession/WSLCGuestVolume.h Supports guest volume mountpoints. No final comments.
src/windows/wslcsession/WSLCGuestVolume.cpp Plumbs guest volume mountpoints. Critical (2 votes): Wrap the constructor call at line 112 to satisfy the 130-column formatting limit.
src/windows/wslc/tasks/VolumeTasks.cpp Implements Docker-style prune output. Critical (2 votes): Wrap the output call at line 229 to satisfy clang-format verification while retaining precision-4 formatting.
src/windows/wslc/tasks/ImageTasks.cpp Uses the renamed size formatter. No final comments.
src/windows/inc/wslc_schema.h Adds inspect fields and custom JSON serialization. Critical (1 vote): Wrap the macro invocation at line 244 to satisfy the 130-column formatting limit.
src/windows/common/string.hpp Adds configurable formatter precision. No final comments.
src/windows/common/string.cpp Implements precision-aware size formatting. No final comments.
localization/strings/en-US/Resources.resw Adds the deleted-volumes header resource. No final comments.
Suppressed comments (1)

src/windows/inc/wslc_schema.h:241

  • The new serializer's non-empty Status branch is only exercised by VHD volumes, but the added inspect test covers a guest volume and the updated VHD test checks Options/Mountpoint without checking Status. A regression here could silently drop HostPath, SizeBytes, or recovery Error from VHD inspect output; add coverage for the emitted VHD status (and the recovery-error case if practical).
    if (volume.Status.has_value() && !volume.Status->empty())
    {
        j["Status"] = *volume.Status;
    }

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

Comment thread src/windows/inc/wslc_schema.h
Comment thread src/windows/wslc/tasks/VolumeTasks.cpp
Comment thread src/windows/wslcsession/WSLCGuestVolume.cpp
@ggarzia-MSFT
ggarzia-MSFT marked this pull request as ready for review August 20, 2026 23:21
@ggarzia-MSFT
ggarzia-MSFT requested review from a team as code owners August 20, 2026 23:21
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 20, 2026 23:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.

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