api/types/system: deprecate DiskUsage.* fields and add type specific fields#51235
Conversation
There was a problem hiding this comment.
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(), andRegistryLogin()methods - Changed
Events()return signature from multiple return values to a singleEventsResultstruct - Created
RegistryLoginOptionsto replace direct use ofregistry.AuthConfigas 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.
client/system_disk_usage.go
Outdated
| // 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 | ||
| } |
There was a problem hiding this comment.
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.
moby/daemon/server/backend/disk_usage.go
Lines 22 to 57 in e30e80d
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
151c2c7 to
e637803
Compare
|
Did a quick rebase, only to fix the merge conflicts; I'll have a look at the |
83747d8 to
da3bcf5
Compare
|
GItHub Unicorns 🦄 |
|
Whoops, needs a rebase |
|
@austinvazquez could you have a peek at #51235 (comment) as well, to see if it's something viable? |
a6223dd to
e059055
Compare
There was a problem hiding this comment.
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.
e059055 to
27304bf
Compare
|
@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. |
0e5072e to
ab9cb23
Compare
ab9cb23 to
d5a844a
Compare
d5a844a to
15c8a54
Compare
|
Added the verbose query and new API responses excluding the extra Items fields. Let's see what breaks before continuing. |
There was a problem hiding this comment.
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.
a03621e to
285334b
Compare
There was a problem hiding this comment.
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.
|
Actually a pretty good start. Looking into the docker-py failures now. |
| du := backend.DiskUsage{} | ||
| if getBuildCache { | ||
| du.BuildCache = &backend.BuildCacheDiskUsage{ |
There was a problem hiding this comment.
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.
285334b to
eff24b0
Compare
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>
eff24b0 to
a69abdd
Compare
|
@vvoland , @thaJeztah, I pushed another revision this time maintaining backwards compatibility for legacy fields on new API versions that do not specify verbose query. |
| * `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`, |
There was a problem hiding this comment.
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.
- What I did
This change deprecates the
api/types/system.DiskUsagetop 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
- A picture of a cute animal (not mandatory but encouraged)