-
Notifications
You must be signed in to change notification settings - Fork 347
Better external image handling #926
Better external image handling #926
Conversation
46e77d9 to
24dee32
Compare
|
@mikebrow Can you take a look at this? This is a more serious issue, because if image loses reference silently, |
mikebrow
left a comment
There was a problem hiding this 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit updateImage(ctx, repoTags...)
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete twice?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Signed-off-by: Lantao Liu <[email protected]>
Signed-off-by: Lantao Liu <[email protected]>
24dee32 to
6905460
Compare
mikebrow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/LGTM
Cherrypick #926 release/1.2
For #909.
For containerd/containerd#2678.
This PR:
io.cri-containerd.imagelabel forcriplugin managed images.ctr, thecriplugin will generate the image id as the unique reference, and apply theio.cri-containerd.imagelabel. This prevents the image from losing all references unexpectedly./cc @dmcgowan