Skip to content

Commit 913b0f5

Browse files
committed
API: omit deprecated VirtualSize field for API v1.44 and up
This field is deprecated since 1261fe6, and will now be omitted on API v1.44 and up for the `GET /images/json`, `GET /images/{id}/json`, and `GET /system/df` endpoints. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 88f4bf4 commit 913b0f5

9 files changed

Lines changed: 29 additions & 38 deletions

File tree

api/server/router/image/image_routes.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
263263
return err
264264
}
265265

266+
version := httputils.VersionFromContext(ctx)
267+
if versions.LessThan(version, "1.44") {
268+
imageInspect.VirtualSize = imageInspect.Size //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
269+
}
266270
return httputils.WriteJSON(w, http.StatusOK, imageInspect)
267271
}
268272

@@ -299,7 +303,6 @@ func (ir *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, er
299303
Os: img.OperatingSystem(),
300304
OsVersion: img.OSVersion,
301305
Size: img.Details.Size,
302-
VirtualSize: img.Details.Size, //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
303306
GraphDriver: types.GraphDriverData{
304307
Name: img.Details.Driver,
305308
Data: img.Details.Metadata,
@@ -357,6 +360,7 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
357360
}
358361

359362
useNone := versions.LessThan(version, "1.43")
363+
withVirtualSize := versions.LessThan(version, "1.44")
360364
for _, img := range images {
361365
if useNone {
362366
if len(img.RepoTags) == 0 && len(img.RepoDigests) == 0 {
@@ -371,6 +375,9 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
371375
img.RepoDigests = []string{}
372376
}
373377
}
378+
if withVirtualSize {
379+
img.VirtualSize = img.Size //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
380+
}
374381
}
375382

376383
return httputils.WriteJSON(w, http.StatusOK, images)

api/server/router/system/system_routes.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
185185
b.Parent = "" //nolint:staticcheck // ignore SA1019 (Parent field is deprecated)
186186
}
187187
}
188+
if versions.LessThan(version, "1.44") {
189+
for _, b := range systemDiskUsage.Images {
190+
b.VirtualSize = b.Size //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
191+
}
192+
}
188193

189194
du := types.DiskUsage{
190195
BuildCache: buildCache,

api/swagger.yaml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,13 +1781,7 @@ definitions:
17811781
description: |
17821782
Total size of the image including all layers it is composed of.
17831783
1784-
In versions of Docker before v1.10, this field was calculated from
1785-
the image itself and all of its parent images. Images are now stored
1786-
self-contained, and no longer use a parent-chain, making this field
1787-
an equivalent of the Size field.
1788-
1789-
> **Deprecated**: this field is kept for backward compatibility, but
1790-
> will be removed in API v1.44.
1784+
Deprecated: this field is omitted in API v1.44, but kept for backward compatibility. Use Size instead.
17911785
type: "integer"
17921786
format: "int64"
17931787
example: 1239828
@@ -1925,12 +1919,7 @@ definitions:
19251919
description: |-
19261920
Total size of the image including all layers it is composed of.
19271921
1928-
In versions of Docker before v1.10, this field was calculated from
1929-
the image itself and all of its parent images. Images are now stored
1930-
self-contained, and no longer use a parent-chain, making this field
1931-
an equivalent of the Size field.
1932-
1933-
Deprecated: this field is kept for backward compatibility, and will be removed in API v1.44.
1922+
Deprecated: this field is omitted in API v1.44, but kept for backward compatibility. Use Size instead.
19341923
type: "integer"
19351924
format: "int64"
19361925
example: 172064416
@@ -9066,7 +9055,6 @@ paths:
90669055
Created: 1466724217
90679056
Size: 1092588
90689057
SharedSize: 0
9069-
VirtualSize: 1092588
90709058
Labels: {}
90719059
Containers: 1
90729060
Containers:

api/types/image_summary.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ type ImageSummary struct {
8484

8585
// Total size of the image including all layers it is composed of.
8686
//
87-
// In versions of Docker before v1.10, this field was calculated from
88-
// the image itself and all of its parent images. Images are now stored
89-
// self-contained, and no longer use a parent-chain, making this field
90-
// an equivalent of the Size field.
91-
//
92-
// Deprecated: this field is kept for backward compatibility, and will be removed in API v1.44.
87+
// Deprecated: this field is omitted in API v1.44, but kept for backward compatibility. Use Size instead.
9388
VirtualSize int64 `json:"VirtualSize,omitempty"`
9489
}

api/types/types.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,7 @@ type ImageInspect struct {
118118
// VirtualSize is the total size of the image including all layers it is
119119
// composed of.
120120
//
121-
// In versions of Docker before v1.10, this field was calculated from
122-
// the image itself and all of its parent images. Docker v1.10 and up
123-
// store images self-contained, and no longer use a parent-chain, making
124-
// this field an equivalent of the Size field.
125-
//
126-
// Deprecated: Unused in API 1.43 and up, but kept for backward compatibility with older API versions.
121+
// Deprecated: this field is omitted in API v1.44, but kept for backward compatibility. Use Size instead.
127122
VirtualSize int64 `json:"VirtualSize,omitempty"`
128123

129124
// GraphDriver holds information about the storage driver used to store the

daemon/containerd/image_list.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ func (i *ImageService) singlePlatformImage(ctx context.Context, contentStore con
250250
RepoDigests: repoDigests,
251251
RepoTags: repoTags,
252252
Size: totalSize,
253-
VirtualSize: totalSize, //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
254253
// -1 indicates that the value has not been set (avoids ambiguity
255254
// between 0 (default) and "not set". We cannot use a pointer (nil)
256255
// for this, as the JSON representation uses "omitempty", which would

daemon/images/image_list.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,10 @@ func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions)
257257

258258
func newImageSummary(image *image.Image, size int64) *types.ImageSummary {
259259
summary := &types.ImageSummary{
260-
ParentID: image.Parent.String(),
261-
ID: image.ID().String(),
262-
Created: image.Created.Unix(),
263-
Size: size,
264-
VirtualSize: size, //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
260+
ParentID: image.Parent.String(),
261+
ID: image.ID().String(),
262+
Created: image.Created.Unix(),
263+
Size: size,
265264
// -1 indicates that the value has not been set (avoids ambiguity
266265
// between 0 (default) and "not set". We cannot use a pointer (nil)
267266
// for this, as the JSON representation uses "omitempty", which would

docs/api/version-history.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ keywords: "API, Docker, rcli, REST, documentation"
1717

1818
[Docker Engine API v1.44](https://docs.docker.com/engine/api/v1.44/) documentation
1919

20+
* The `VirtualSize` field in the `GET /images/{name}/json`, `GET /images/json`,
21+
and `GET /system/df` responses is now omitted. Use the `Size` field instead,
22+
which contains the same information.
23+
2024
## v1.43 API changes
2125

2226
[Docker Engine API v1.43](https://docs.docker.com/engine/api/v1.43/) documentation

integration/system/disk_usage_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ func TestDiskUsage(t *testing.T) {
5757
LayersSize: du.LayersSize,
5858
Images: []*types.ImageSummary{
5959
{
60-
Created: du.Images[0].Created,
61-
ID: du.Images[0].ID,
62-
RepoTags: []string{"busybox:latest"},
63-
Size: du.LayersSize,
64-
VirtualSize: du.LayersSize, //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
60+
Created: du.Images[0].Created,
61+
ID: du.Images[0].ID,
62+
RepoTags: []string{"busybox:latest"},
63+
Size: du.LayersSize,
6564
},
6665
},
6766
Containers: []*types.Container{},

0 commit comments

Comments
 (0)