diff --git a/cri/v1alpha1/cri.go b/cri/v1alpha1/cri.go index 477ce659a..7a3ac910a 100644 --- a/cri/v1alpha1/cri.go +++ b/cri/v1alpha1/cri.go @@ -710,11 +710,16 @@ func (c *CriManager) ContainerStatus(ctx context.Context, r *runtime.ContainerSt labels, annotations := extractLabels(container.Config.Labels) - imageRef := container.Image - imageInfo, err := c.ImageMgr.GetImage(ctx, imageRef) + // FIXME(fuwei): if user repush image with the same reference, the image + // ID will be changed. For now, pouch daemon will remove the old image ID + // so that CRI fails to fetch the running container. Before upgrade + // pouch daemon image manager, we use reference to get image instead of + // id. + imageInfo, err := c.ImageMgr.GetImage(ctx, container.Config.Image) if err != nil { - return nil, fmt.Errorf("failed to get image %s: %v", imageRef, err) + return nil, fmt.Errorf("failed to get image %s: %v", container.Config.Image, err) } + imageRef := imageInfo.ID if len(imageInfo.RepoDigests) > 0 { imageRef = imageInfo.RepoDigests[0] } diff --git a/cri/v1alpha2/cri.go b/cri/v1alpha2/cri.go index ab46b7db3..5fedaa50c 100644 --- a/cri/v1alpha2/cri.go +++ b/cri/v1alpha2/cri.go @@ -709,11 +709,16 @@ func (c *CriManager) ContainerStatus(ctx context.Context, r *runtime.ContainerSt labels, annotations := extractLabels(container.Config.Labels) - imageRef := container.Image - imageInfo, err := c.ImageMgr.GetImage(ctx, imageRef) + // FIXME(fuwei): if user repush image with the same reference, the image + // ID will be changed. For now, pouch daemon will remove the old image ID + // so that CRI fails to fetch the running container. Before upgrade + // pouch daemon image manager, we use reference to get image instead of + // id. + imageInfo, err := c.ImageMgr.GetImage(ctx, container.Config.Image) if err != nil { - return nil, fmt.Errorf("failed to get image %s: %v", imageRef, err) + return nil, fmt.Errorf("failed to get image %s: %v", container.Config.Image, err) } + imageRef := imageInfo.ID if len(imageInfo.RepoDigests) > 0 { imageRef = imageInfo.RepoDigests[0] }