Skip to content

Commit

Permalink
Merge pull request #2096 from fuweid/bugfix_use_config_image_instead_…
Browse files Browse the repository at this point in the history
…of_id

bugfix: use image reference during ContainerStatus
  • Loading branch information
allencloud authored Aug 15, 2018
2 parents 0f65a73 + 4ab5892 commit 18df365
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions cri/v1alpha1/cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,11 +718,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]
}
Expand Down
11 changes: 8 additions & 3 deletions cri/v1alpha2/cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,11 +717,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]
}
Expand Down

0 comments on commit 18df365

Please sign in to comment.