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

Commit

Permalink
check image readiness when recover
Browse files Browse the repository at this point in the history
fix #303

Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
  • Loading branch information
yanxuean committed Oct 12, 2017
1 parent 9135ef2 commit 748ec2c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/server/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import (
"golang.org/x/net/context"
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"

imagemanage "github.com/containerd/containerd/images"
"github.com/containerd/containerd/platforms"
cio "github.com/kubernetes-incubator/cri-containerd/pkg/server/io"
containerstore "github.com/kubernetes-incubator/cri-containerd/pkg/store/container"
imagestore "github.com/kubernetes-incubator/cri-containerd/pkg/store/image"
Expand Down Expand Up @@ -101,6 +103,10 @@ 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)
continue
}
c.imageStore.Add(image)
glog.V(4).Infof("Loaded image %+v", image)
}
Expand Down Expand Up @@ -327,6 +333,12 @@ func loadImages(ctx context.Context, cImages []containerd.Image, provider conten
// Group images by image id.
imageMap := make(map[string][]containerd.Image)
for _, i := range cImages {
glog.Infof("check image readiness for %+v: %+v", i.Name(), i.Target())
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)
continue
}

desc, err := i.Config(ctx)
if err != nil {
glog.Warningf("Failed to get image config for %q: %v", i.Name(), err)
Expand Down

0 comments on commit 748ec2c

Please sign in to comment.