Переглянути джерело

Merge pull request #42608 from rvolosatovs/fix_builder_size

Deprecate `BuilderSize` in API versions >= 1.42
Sebastiaan van Stijn 4 роки тому
батько
коміт
bf78e25fe5

+ 6 - 4
api/server/router/system/system_routes.go

@@ -113,12 +113,14 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
 		return err
 	}
 
-	var builderSize int64
-	for _, b := range buildCache {
-		builderSize += b.Size
+	if versions.LessThan(httputils.VersionFromContext(ctx), "1.42") {
+		var builderSize int64
+		for _, b := range buildCache {
+			builderSize += b.Size
+		}
+		du.BuilderSize = builderSize
 	}
 
-	du.BuilderSize = builderSize
 	du.BuildCache = buildCache
 	if buildCache == nil {
 		// Ensure empty `BuildCache` field is represented as empty JSON array(`[]`)

+ 1 - 1
api/types/types.go

@@ -538,7 +538,7 @@ type DiskUsage struct {
 	Containers  []*Container
 	Volumes     []*Volume
 	BuildCache  []*BuildCache
-	BuilderSize int64 // deprecated
+	BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40.
 }
 
 // ContainersPruneReport contains the response for Engine API:

+ 5 - 0
docs/api/version-history.md

@@ -17,6 +17,11 @@ keywords: "API, Docker, rcli, REST, documentation"
 
 [Docker Engine API v1.42](https://docs.docker.com/engine/api/v1.42/) documentation
 
+* Removed the `BuilderSize` field on the `GET /system/df` endpoint. This field
+  was introduced in API 1.31 as part of an experimental feature, and no longer
+  used since API 1.40.
+  Use field `BuildCache` instead to track storage used by the builder component.
+
 ## v1.41 API changes
 
 [Docker Engine API v1.41](https://docs.docker.com/engine/api/v1.41/) documentation