瀏覽代碼

Don't return an error if the lease is not found

If the image for the wanted platform doesn't exist then the lease
doesn't exist either. Returning this error hides the real error, so
let's not return it.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
Djordje Lukic 1 年之前
父節點
當前提交
b8ff8ea58e
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      daemon/images/image.go

+ 7 - 4
daemon/images/image.go

@@ -54,10 +54,13 @@ func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, image str
 func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.Image, platform ocispec.Platform) (bool, error) {
 func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.Image, platform ocispec.Platform) (bool, error) {
 	logger := log.G(ctx).WithField("image", img.ID).WithField("desiredPlatform", platforms.Format(platform))
 	logger := log.G(ctx).WithField("image", img.ID).WithField("desiredPlatform", platforms.Format(platform))
 
 
-	ls, leaseErr := i.leases.ListResources(ctx, leases.Lease{ID: imageKey(img.ID().String())})
-	if leaseErr != nil {
-		logger.WithError(leaseErr).Error("Error looking up image leases")
-		return false, leaseErr
+	ls, err := i.leases.ListResources(ctx, leases.Lease{ID: imageKey(img.ID().String())})
+	if err != nil {
+		if cerrdefs.IsNotFound(err) {
+			return false, nil
+		}
+		logger.WithError(err).Error("Error looking up image leases")
+		return false, err
 	}
 	}
 
 
 	// Note we are comparing against manifest lists here, which we expect to always have a CPU variant set (where applicable).
 	// Note we are comparing against manifest lists here, which we expect to always have a CPU variant set (where applicable).