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

check image readiness when recover #345

Merged
merged 1 commit into from
Oct 23, 2017

Conversation

yanxuean
Copy link
Member

fix #303

Signed-off-by: yanxuean yan.xuean@zte.com.cn

@Random-Liu
Copy link
Member

/test all

@mikebrow
Copy link
Member

/test all

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.

Question / nit...

@@ -101,6 +103,11 @@ func (c *criContainerdService) recover(ctx context.Context) error {
return fmt.Errorf("failed to load images: %v", err)
}
for _, image := range images {
if _, err := c.client.SnapshotService(c.config.ContainerdConfig.Snapshotter).Stat(ctx, image.ChainID); err != nil {
glog.Warningf("Failed to check top snapshot %+v: %v", image, err)
Copy link
Member

Choose a reason for hiding this comment

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

top snapshot?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. What do you suggest?

Copy link
Member

@mikebrow mikebrow Oct 19, 2017

Choose a reason for hiding this comment

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

"Failed to stat the top-level snapshot for image %+v: %v"
or
"Failed to locate information for snapshot using chainid for image %+v: %v"

Copy link
Member Author

Choose a reason for hiding this comment

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

We want to check readiness of top snapshot. We do it by calling Stat() function now.
Is the error message better to indicating our purpose?

Copy link
Member

@mikebrow mikebrow Oct 19, 2017

Choose a reason for hiding this comment

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

I understand your meaning and the issue description but most won't. Top snapshot could have many meanings. Images have layers.. the image.chainid points to the top-level layer for an image snapshot and contains references to the rest of the layers. IMO it's better to just say what failed vs. using the issue description of what needed to be done here.

For example: "Failed to locate information for snapshot using chainid for image %+v: %v"
As another example: "Failed to stat the top-level snapshot for image %+v: %v"
I think those are more explanatory to the reader of the warnings than: "Failed to check top snapshot %+v: %v"

What do you think?

You could add a comment above the if test stating the purpose of the check:
// Checking existence of top-level snapshot for each image being recovered.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right. You have a lot of experience,we need to learn from you.:)
Thank for your review and guidance.

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

@yanxuean yanxuean force-pushed the imagereadiness branch 2 times, most recently from 3ba1186 to 6772474 Compare October 20, 2017 02:57
@mikebrow
Copy link
Member

/test all

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

@@ -26,6 +26,8 @@ import (
"github.com/containerd/containerd"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
imagemanage "github.com/containerd/containerd/images"
Copy link
Member

Choose a reason for hiding this comment

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

This name is confusing. I prefer containerdimages if we really need another name for the package.

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

@@ -101,6 +103,12 @@ func (c *criContainerdService) recover(ctx context.Context) error {
return fmt.Errorf("failed to load images: %v", err)
}
for _, image := range images {
// Checking existence of top-level snapshot for each image being recovered.
Copy link
Member

Choose a reason for hiding this comment

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

Why not add this logic into loadImages function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because we need call c.client.SnapshotService.

Copy link
Member

Choose a reason for hiding this comment

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

Just pass it in. :)

Copy link
Member

@Random-Liu Random-Liu Oct 23, 2017

Choose a reason for hiding this comment

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

I feel like logically this should be part of loadImages, we load it only when it is ready.
In the future, we may need to recover the snapshot or something, which all should be handled in loadImages instead of here.

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

@@ -342,6 +350,10 @@ func loadImages(ctx context.Context, cImages []containerd.Image, provider conten
// imgs len must be > 0, or else the entry will not be created in
// previous loop.
i := imgs[0]
if ok, _, _, _, err := imagemanage.Check(ctx, provider, i.Target(), platforms.Default()); !ok || err != nil {
glog.Warningf("Failed to check image readiness for %q: %v", i.Name(), err)
Copy link
Member

Choose a reason for hiding this comment

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

Let's log different for !ok and 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.

Failed to check image content readiness for %q: %v

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

fix containerd#303

Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
@Random-Liu Random-Liu merged commit 698f0ea into containerd:master Oct 23, 2017
@Random-Liu
Copy link
Member

LGTM

@yanxuean yanxuean deleted the imagereadiness branch October 24, 2017 00:28
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.

Use containerd image readiness check function to properly recover image during restart.
4 participants