From c441b2ef19feb9ce2b97eb0ebd40e0b1a45344a7 Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Thu, 4 Sep 2025 08:04:57 -0500 Subject: [PATCH] api/types/image: make `InspectResponse.GraphDriver` optional This change makes the `GraphDriver` field in `image.InspectResponse` optional. This field will only be returned when using moby engine graph drivers as a backend storage implementation. It will be omitted when using the containerd image backend. Signed-off-by: Austin Vazquez --- api/swagger.yaml | 1 + api/types/image/image_inspect.go | 2 +- daemon/containerd/image_inspect.go | 5 ----- daemon/images/image_inspect.go | 2 +- integration/daemon/default_storage_test.go | 4 +++- vendor/github.com/moby/moby/api/types/image/image_inspect.go | 2 +- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/api/swagger.yaml b/api/swagger.yaml index 08628a3918..2fb2052360 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -2057,6 +2057,7 @@ definitions: format: "int64" example: 1239828 GraphDriver: + x-nullable: true $ref: "#/definitions/DriverData" RootFS: description: | diff --git a/api/types/image/image_inspect.go b/api/types/image/image_inspect.go index 4335f733d5..69a2637563 100644 --- a/api/types/image/image_inspect.go +++ b/api/types/image/image_inspect.go @@ -111,7 +111,7 @@ type InspectResponse struct { // GraphDriver holds information about the storage driver used to store the // container's and image's filesystem. - GraphDriver storage.DriverData + GraphDriver *storage.DriverData `json:"GraphDriver,omitempty"` // RootFS contains information about the image's RootFS, including the // layer IDs. diff --git a/daemon/containerd/image_inspect.go b/daemon/containerd/image_inspect.go index d2d1bb0f65..dfa7a4575e 100644 --- a/daemon/containerd/image_inspect.go +++ b/daemon/containerd/image_inspect.go @@ -12,7 +12,6 @@ import ( "github.com/distribution/reference" imagespec "github.com/moby/docker-image-spec/specs-go/v1" imagetypes "github.com/moby/moby/api/types/image" - "github.com/moby/moby/api/types/storage" "github.com/moby/moby/v2/daemon/internal/sliceutil" "github.com/moby/moby/v2/daemon/server/backend" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -95,10 +94,6 @@ func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, opts ba DockerVersion: "", Size: size, Manifests: manifests, - GraphDriver: storage.DriverData{ - Name: i.snapshotter, - Data: nil, - }, Metadata: imagetypes.Metadata{ LastTagTime: lastUpdated, }, diff --git a/daemon/images/image_inspect.go b/daemon/images/image_inspect.go index 77292950e7..749f64d8a5 100644 --- a/daemon/images/image_inspect.go +++ b/daemon/images/image_inspect.go @@ -71,7 +71,7 @@ func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, opts ba Os: img.OperatingSystem(), OsVersion: img.OSVersion, Size: size, - GraphDriver: storage.DriverData{ + GraphDriver: &storage.DriverData{ Name: i.layerStore.DriverName(), Data: layerMetadata, }, diff --git a/integration/daemon/default_storage_test.go b/integration/daemon/default_storage_test.go index 0a63a4671e..40431ece4f 100644 --- a/integration/daemon/default_storage_test.go +++ b/integration/daemon/default_storage_test.go @@ -73,8 +73,10 @@ func TestGraphDriverPersistence(t *testing.T) { assert.Check(t, is.Equal(info.Driver, prevDriver)) // Verify our image is still there - _, err = c.ImageInspect(ctx, testImage) + imageInspect, err := c.ImageInspect(ctx, testImage) assert.NilError(t, err, "Test image should still be available after daemon restart") + assert.Check(t, imageInspect.GraphDriver != nil, "GraphDriver should be set for graphdriver backend") + assert.Check(t, is.Equal(imageInspect.GraphDriver.Name, prevDriver), "Image graphdriver data should match") // Verify our container is still there _, err = c.ContainerInspect(ctx, containerID) diff --git a/vendor/github.com/moby/moby/api/types/image/image_inspect.go b/vendor/github.com/moby/moby/api/types/image/image_inspect.go index 4335f733d5..69a2637563 100644 --- a/vendor/github.com/moby/moby/api/types/image/image_inspect.go +++ b/vendor/github.com/moby/moby/api/types/image/image_inspect.go @@ -111,7 +111,7 @@ type InspectResponse struct { // GraphDriver holds information about the storage driver used to store the // container's and image's filesystem. - GraphDriver storage.DriverData + GraphDriver *storage.DriverData `json:"GraphDriver,omitempty"` // RootFS contains information about the image's RootFS, including the // layer IDs.