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 during restart
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 17, 2017
1 parent 6ed27ad commit c78347a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 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,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)
continue
}

glog.V(4).Infof("Loaded image %+v", image)
if err := c.imageStore.Add(image); err != nil {
return fmt.Errorf("failed to add image %q to store: %v", image.ID, err)
Expand Down Expand Up @@ -342,6 +349,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)
continue
}
info, err := getImageInfo(ctx, i, provider)
if err != nil {
glog.Warningf("Failed to get image info for %q: %v", i.Name(), err)
Expand Down

0 comments on commit c78347a

Please sign in to comment.