cri: patch update image labels

The CRI-plugin subscribes the image event on k8s.io namespace. By
default, the image event is created by CRI-API. However, the image can
be downloaded by containerd API on k8s.io with the customized labels.
The CRI-plugin should use patch update for `io.cri-containerd.image`
label in this case.

Fixes: #5900

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu 2021-09-05 18:48:26 +08:00
parent 61a46e9fdd
commit 2bcd6a4e88

View File

@ -233,7 +233,7 @@ func (c *criService) createImageReference(ctx context.Context, name string, desc
if oldImg.Target.Digest == img.Target.Digest && oldImg.Labels[imageLabelKey] == imageLabelValue { if oldImg.Target.Digest == img.Target.Digest && oldImg.Labels[imageLabelKey] == imageLabelValue {
return nil return nil
} }
_, err = c.client.ImageService().Update(ctx, img, "target", "labels") _, err = c.client.ImageService().Update(ctx, img, "target", "labels."+imageLabelKey)
return err return err
} }