Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Conversation

@Random-Liu
Copy link
Member

@Random-Liu Random-Liu commented Sep 26, 2018

For #909.
For containerd/containerd#2678.

This PR:

  1. Add io.cri-containerd.image label for cri plugin managed images.
  2. For images pulled/imported by other clients, e.g. ctr, the cri plugin will generate the image id as the unique reference, and apply the io.cri-containerd.image label. This prevents the image from losing all references unexpectedly.
  3. Add 2 integration tests: "image can be recovered during restart" and "image pulled with containerd client can be seen by CRI plugin".

/cc @dmcgowan

@Random-Liu Random-Liu added this to the v1.2 milestone Sep 26, 2018
@Random-Liu Random-Liu force-pushed the better-external-image-handling branch 2 times, most recently from 46e77d9 to 24dee32 Compare September 26, 2018 07:20
@Random-Liu
Copy link
Member Author

Random-Liu commented Sep 27, 2018

@mikebrow Can you take a look at this? This is a more serious issue, because if image loses reference silently, ContainerStatus will always fail because it can't convert image id to repotag and repodigest. This line https://github.com/containerd/cri/blob/master/pkg/server/container_status.go#L45 will always fail.

Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see nit .. overall looks good to me

// Image imported by importer.Import is not treated as managed
// by the cri plugin, call `updateImage` to make it managed.
// TODO(random-liu): Replace this with the containerd library (issue #909).
if err := c.updateImage(ctx, repoTag); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit updateImage(ctx, repoTags...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it one by one, we need the log below

// updateImage updates image store to reflect the newest state of an image reference
// in containerd. If the reference is not managed by the cri plugin, the function also
// generates necessary metadata for the image and make it managed.
func (c *criService) updateImage(ctx context.Context, r string) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest: func (c *criService) updateImage(ctx context.Context, refs ...string) error

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

if err := containerdClient.ImageService().Delete(ctx, testImage); err != nil {
assert.True(t, errdefs.IsNotFound(err), err)
}
if err := containerdClient.ImageService().Delete(ctx, testImage); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete twice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad... The second time should be the image id... The test shouldn't pass then... Let me see.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. The reason is that after the tag is deleted, we can't reference the image by tag, but we can still reference it by id. This is expected behavior.

I've updated the test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@Random-Liu Random-Liu force-pushed the better-external-image-handling branch from 24dee32 to 6905460 Compare September 27, 2018 18:37
Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/LGTM

@Random-Liu Random-Liu merged commit 58ab1e0 into containerd:master Sep 27, 2018
@Random-Liu Random-Liu deleted the better-external-image-handling branch September 27, 2018 20:19
Random-Liu added a commit that referenced this pull request Sep 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants