Repository: moby/moby (language: go)

Issue:
containerd integration: image save/load should produce a JSON stream and image events 
### Description

- relates to https://github.com/moby/moby/pull/43822

The existing (non-containerd) implementation writes to a progress stream when loading images; this is currently missing in the containerd implementation; e.g.; https://github.com/moby/moby/blob/7e8df0e2c90265b64ae7e9b8023258b719a596d6/image/tarexport/load.go#L132

https://github.com/moby/moby/blob/7e8df0e2c90265b64ae7e9b8023258b719a596d6/image/tarexport/load.go#L149


In addition, the existing implementation generates "image load" and "image save" events;
https://github.com/moby/moby/blob/7e8df0e2c90265b64ae7e9b8023258b719a596d6/image/tarexport/load.go#L137
https://github.com/moby/moby/blob/7e8df0e2c90265b64ae7e9b8023258b719a596d6/image/tarexport/save.go#L227


Discussion / hints:

Fix patch:
diff --git a/daemon/containerd/image_exporter.go b/daemon/containerd/image_exporter.go
index 44fada7c46586..59aa1d4ccf3d4 100644
--- a/daemon/containerd/image_exporter.go
+++ b/daemon/containerd/image_exporter.go
@@ -102,8 +102,6 @@ func (i *ImageService) ExportImage(ctx context.Context, names []string, outStrea
 // LoadImage uploads a set of images into the repository. This is the
 // complement of ExportImage.  The input stream is an uncompressed tar
 // ball containing images and metadata.
-//
-// TODO(thaJeztah): produce JSON stream progress response and image events; see https://github.com/moby/moby/issues/43910
 func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error {
 	// TODO(vvoland): Allow user to pass platform
 	platform := cplatforms.All
@@ -153,7 +151,9 @@ func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, outSt
 		}
 
 		fmt.Fprintf(progress, "Loaded image: %s\n", name)
+		i.LogImageEvent(img.Target.Digest.String(), img.Target.Digest.String(), "load")
 	}
+
 	return nil
 }
 
diff --git a/daemon/containerd/image_import.go b/daemon/containerd/image_import.go
index bbb989d6668eb..592c7f294ebd6 100644
--- a/daemon/containerd/image_import.go
+++ b/daemon/containerd/image_import.go
@@ -146,6 +146,8 @@ func (i *ImageService) ImportImage(ctx context.Context, ref reference.Named, pla
 	err = i.unpackImage(ctx, img, *platform)
 	if err != nil {
 		logger.WithError(err).Debug("failed to unpack image")
+	} else {
+		i.LogImageEvent(id.String(), id.String(), "import")
 	}
 
 	return id, err


Test patch: