Skip to content

api/types/system: deprecate DiskUsage.* fields and add type specific fields#51235

Merged
thaJeztah merged 1 commit intomoby:masterfrom
austinvazquez:refactor-client-system
Nov 5, 2025
Merged

api/types/system: deprecate DiskUsage.* fields and add type specific fields#51235
thaJeztah merged 1 commit intomoby:masterfrom
austinvazquez:refactor-client-system

Conversation

@austinvazquez
Copy link
Contributor

@austinvazquez austinvazquez commented Oct 20, 2025

- What I did

This change deprecates the api/types/system.DiskUsage top level fields and adds new type specific fields. Additionally this change adds to the client new wrapper structs for options/results.

- How I did it

- How to verify it

- Human readable description for the release notes

api/types/system: deprecated top level `DiskUsage` fields for type specific fields.

- A picture of a cute animal (not mandatory but encouraged)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the client API to wrap system-related method responses in dedicated result types, improving API consistency and extensibility. The changes introduce wrapper types (SystemInfoResult, PingResult, EventsResult, DiskUsageResult, RegistryLoginResult) that encapsulate the original response data, along with a new RegistryLoginOptions type for better parameter handling.

Key changes:

  • Introduced wrapper result types for Info(), Ping(), Events(), DiskUsage(), and RegistryLogin() methods
  • Changed Events() return signature from multiple return values to a single EventsResult struct
  • Created RegistryLoginOptions to replace direct use of registry.AuthConfig as method parameter
  • Updated all call sites across integration tests and internal utilities to unwrap the new result types

Reviewed Changes

Copilot reviewed 34 out of 42 changed files in this pull request and generated no comments.

Show a summary per file
File Description
client/system_info.go Introduces SystemInfoResult wrapper and updates Info() return type
client/ping.go Introduces PingResult wrapper and updates Ping() return type
client/system_events.go Introduces EventsResult wrapper and changes Events() from returning two channels to a single result struct
client/system_disk_usage.go Introduces DiskUsageResult wrapper, moves DiskUsageOptions from separate file, updates DiskUsage() return type
client/system_disk_usage_opts.go Deleted (options moved to system_disk_usage.go)
client/login.go Introduces RegistryLoginOptions and RegistryLoginResult, updates RegistryLogin() signature
client/client_interfaces.go Updates SystemAPIClient interface to reflect new method signatures
client/client.go Updates calls to Ping() to unwrap PingResult
integration/system/*.go Updates test code to unwrap new result types from Info(), Ping(), Events(), and DiskUsage()
integration/container/*.go Updates test code to unwrap new result types
integration/plugin/authz/*.go Updates test code to unwrap new result types
integration/networking/*.go Updates test code to unwrap new result types
integration/build/*.go Updates test code to unwrap new result types
integration-cli/*.go Updates legacy test code to unwrap new result types
internal/testutil//.go Updates utility functions to unwrap new result types
client/system_info_test.go Updates unit tests to unwrap SystemInfoResult
client/system_events_test.go Updates unit tests to use EventsResult struct fields
client/ping_test.go Updates unit tests to unwrap PingResult

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +12 to +17
// DiskUsageOptions holds parameters for system disk usage query.
type DiskUsageOptions struct {
// Types specifies what object types to include in the response. If empty,
// all object types are returned.
Types []system.DiskUsageObject
}
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if we should start aligning this one with the backend.DiskUsage type; the "fun" thing there is that the daemon was rewritten to produce that new type, but it was never wired up, so the API continued producing the old format;

But as we'll now separating the client's output struct from the underlying API response, possibly we could already align it with that, then in future change the API response.

// DiskUsage contains the information returned by the backend for the
// GET "/system/df" endpoint.
type DiskUsage struct {
Images *ImageDiskUsage
Containers *ContainerDiskUsage
Volumes *VolumeDiskUsage
BuildCache *BuildCacheDiskUsage
}
// BuildCacheDiskUsage contains disk usage for the build cache.
type BuildCacheDiskUsage struct {
TotalSize int64
Reclaimable int64
Items []*build.CacheRecord
}
// ContainerDiskUsage contains disk usage for containers.
type ContainerDiskUsage struct {
TotalSize int64
Reclaimable int64
Items []*container.Summary
}
// ImageDiskUsage contains disk usage for images.
type ImageDiskUsage struct {
TotalSize int64
Reclaimable int64
Items []*image.Summary
}
// VolumeDiskUsage contains disk usage for volumes.
type VolumeDiskUsage struct {
TotalSize int64
Reclaimable int64
Items []*volume.Volume
}

Currently we have code in the CLI doing that conversion, but that could potentially be moved to the client if the shape of the result allows it.
https://github.com/docker/cli/blob/644dc16b169c1cf1bab56af34eedfe3c1378fb58/cli/command/formatter/disk_usage.go#L295-L312

@thaJeztah thaJeztah added the release-blocker PRs we want to block a release on label Oct 21, 2025
@thaJeztah thaJeztah added this to the 29.0.0 milestone Oct 21, 2025
@thaJeztah thaJeztah force-pushed the refactor-client-system branch from 151c2c7 to e637803 Compare October 22, 2025 08:04
@thaJeztah
Copy link
Member

Did a quick rebase, only to fix the merge conflicts; I'll have a look at the Ping (and swarm.Status) structs now.

@thaJeztah
Copy link
Member

GItHub Unicorns 🦄

Step 9/13 : ADD [https://github.com/moby/busybox/releases/download/${BUSYBOX_VERSION}/busybox-w32-${BUSYBOX_VERSION}.exe](https://github.com/moby/busybox/releases/download/$%7BBUSYBOX_VERSION%7D/busybox-w32-$%7BBUSYBOX_VERSION%7D.exe) /bin/busybox.exe
ADD failed: failed to GET https://github.com/moby/busybox/releases/download/FRP-5007-g82accfc19/busybox-w32-FRP-5007-g82accfc19.exe with status 503 Service Unavailable: <!DOCTYPE html>
<!--

Hello future GitHubber! I bet you're here to remove those nasty inline styles,
DRY up these templates and make 'em nice and re-usable, right?

Please, don't. https://github.com/styleguide/templates/2.0

-->
<html>
  <head>
    <title>Unicorn! &middot; GitHub</title>
    <style type="text/css" media="screen">
      body {
        background-color: #f1f1f1;
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
      }

@vvoland
Copy link
Contributor

vvoland commented Oct 22, 2025

Whoops, needs a rebase

@thaJeztah
Copy link
Member

@austinvazquez could you have a peek at #51235 (comment) as well, to see if it's something viable?

@austinvazquez austinvazquez force-pushed the refactor-client-system branch 2 times, most recently from a6223dd to e059055 Compare October 24, 2025 21:35
@austinvazquez austinvazquez requested a review from Copilot October 24, 2025 21:37
Copy link

Copilot AI left a comment

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 30 out of 36 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@austinvazquez austinvazquez force-pushed the refactor-client-system branch from e059055 to 27304bf Compare October 25, 2025 00:26
@austinvazquez
Copy link
Contributor Author

@thaJeztah , @vvoland if you folks could ptal here. The latest revision implements the disk usage result with both older and newer shapes of disk usage.

@thaJeztah thaJeztah force-pushed the refactor-client-system branch from 0e5072e to ab9cb23 Compare October 29, 2025 08:42
@austinvazquez austinvazquez force-pushed the refactor-client-system branch from ab9cb23 to d5a844a Compare October 29, 2025 13:34
@austinvazquez austinvazquez force-pushed the refactor-client-system branch from d5a844a to 15c8a54 Compare October 30, 2025 16:55
@austinvazquez austinvazquez requested a review from tianon as a code owner October 30, 2025 16:55
@austinvazquez austinvazquez marked this pull request as draft October 30, 2025 16:56
@austinvazquez
Copy link
Contributor Author

Added the verbose query and new API responses excluding the extra Items fields. Let's see what breaks before continuing.

@austinvazquez austinvazquez requested a review from Copilot October 30, 2025 17:01
Copy link

Copilot AI left a comment

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 19 out of 27 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@austinvazquez austinvazquez force-pushed the refactor-client-system branch 2 times, most recently from a03621e to 285334b Compare October 30, 2025 18:57
@austinvazquez austinvazquez requested a review from Copilot October 30, 2025 19:01
Copy link

Copilot AI left a comment

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 19 out of 27 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@austinvazquez
Copy link
Contributor Author

Actually a pretty good start. Looking into the docker-py failures now.

Comment on lines -207 to -209
du := backend.DiskUsage{}
if getBuildCache {
du.BuildCache = &backend.BuildCacheDiskUsage{
Copy link
Member

Choose a reason for hiding this comment

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

For API < v1.52 we can keep the old conversion code and return the old API struct; move the old API struct in the backend, and use it as response type for API <v1.52.

@austinvazquez austinvazquez force-pushed the refactor-client-system branch from 285334b to eff24b0 Compare October 31, 2025 00:41
@austinvazquez austinvazquez marked this pull request as ready for review October 31, 2025 01:00
@vvoland vvoland self-requested a review October 31, 2025 16:42
This change adds type specific fields to `GET /system/df` endpoint with high level information of disk usage. This change also introduces `verbose` query to the endpoint so that detailed information is by default excluded unless queried to reduce memory consumption. The previous top level `DiskUsage` fields (`Images`, `Containers`, `Volumes` and `BuildCache`) are now deprecated and kept for backwards compatibility.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
@austinvazquez austinvazquez force-pushed the refactor-client-system branch from eff24b0 to a69abdd Compare November 3, 2025 22:34
@austinvazquez
Copy link
Contributor Author

@vvoland , @thaJeztah, I pushed another revision this time maintaining backwards compatibility for legacy fields on new API versions that do not specify verbose query.

Copy link
Contributor

@vvoland vvoland left a comment

Choose a reason for hiding this comment

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

LGTM

* `GET /system/df` returns `ImagesUsage`, `ContainersUsage`, `VolumesUsage`, and
`BuildCacheUsage` fields with brief system disk usage data for each system object type.
The endpoint supports the `?verbose=1` query to return verbose system disk usage information.
* Deprecated: `GET /system/df` response fields `LayersSize`, `Images`, `Containers`,
Copy link
Member

Choose a reason for hiding this comment

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

Removed is indeed probably more correct, but I think we're currently still returning them with this PR.

I'll have a look in a follow-up to see if we can make a clean cut (< v1.52, >= v1.52); for the docker-py tests, we need to check, because using "yolo-latest" (un-versioned API) has been deprecated for some years, and generally should not be used.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah thaJeztah merged commit b075a39 into moby:master Nov 5, 2025
283 of 288 checks passed
@austinvazquez austinvazquez deleted the refactor-client-system branch November 5, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants