diff --git a/api/server/router/system/system_routes.go b/api/server/router/system/system_routes.go index 01addc6754..504da5cb69 100644 --- a/api/server/router/system/system_routes.go +++ b/api/server/router/system/system_routes.go @@ -174,6 +174,8 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter, if versions.LessThan(version, "1.42") { for _, b := range buildCache { builderSize += b.Size + // Parents field was added in API 1.42 to replace the Parent field. + b.Parents = nil } } if versions.GreaterThanOrEqualTo(version, "1.42") { diff --git a/api/swagger.yaml b/api/swagger.yaml index 81197b6097..fa2933fe70 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -2263,6 +2263,14 @@ definitions: type: "string" x-nullable: true example: "" + Parents: + description: | + List of parent build cache record IDs. + type: "array" + items: + type: "string" + x-nullable: true + example: ["hw53o5aio51xtltp5xjp8v7fx"] Type: type: "string" description: | @@ -9068,6 +9076,7 @@ paths: BuildCache: - ID: "hw53o5aio51xtltp5xjp8v7fx" + Parents: [] Type: "regular" Description: "pulled from docker.io/library/debian@sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0" InUse: false @@ -9078,6 +9087,7 @@ paths: UsageCount: 26 - ID: "ndlpt0hhvkqcdfkputsk4cq9c" + Parents: ["ndlpt0hhvkqcdfkputsk4cq9c"] Type: "regular" Description: "mount / from exec /bin/sh -c echo 'Binary::apt::APT::Keep-Downloaded-Packages \"true\";' > /etc/apt/apt.conf.d/keep-cache" InUse: false diff --git a/api/types/types.go b/api/types/types.go index 346d010cff..ab4b7fb829 100644 --- a/api/types/types.go +++ b/api/types/types.go @@ -778,8 +778,10 @@ type BuildCache struct { ID string // Parent is the ID of the parent build cache record. // - // Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit. + // Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit; use Parents instead. Parent string `json:"Parent,omitempty"` + // Parents is the list of parent build cache record IDs. + Parents []string `json:" Parents,omitempty"` // Type is the cache record type. Type string // Description is a description of the build-step that produced the build cache. diff --git a/builder/builder-next/builder.go b/builder/builder-next/builder.go index 15fdb9fc40..a88e8b5751 100644 --- a/builder/builder-next/builder.go +++ b/builder/builder-next/builder.go @@ -130,6 +130,7 @@ func (b *Builder) DiskUsage(ctx context.Context) ([]*types.BuildCache, error) { items = append(items, &types.BuildCache{ ID: r.ID, Parent: r.Parent, //nolint:staticcheck // ignore SA1019 (Parent field is deprecated) + Parents: r.Parents, Type: r.RecordType, Description: r.Description, InUse: r.InUse, diff --git a/docs/api/version-history.md b/docs/api/version-history.md index b8ec2a38da..36482c5479 100644 --- a/docs/api/version-history.md +++ b/docs/api/version-history.md @@ -89,6 +89,8 @@ keywords: "API, Docker, rcli, REST, documentation" with information about the created volume. * The `BuildCache.Parent` field, as returned by `GET /system/df` is deprecated and is now omitted. API versions before v1.42 continue to include this field. +* `GET /system/df` now includes a new `Parents` field, for "build-cache" records, + which contains a list of parent IDs for the build-cache record. * Volume information returned by `GET /volumes/{name}`, `GET /volumes` and `GET /system/df` can now contain a `ClusterVolume` if the volume is a cluster volume (requires the daemon to be a Swarm manager).