Merge pull request #9815 from kiashok/updateCRIServicePull
Pass runtimehandler from CRI to pull image request
This commit is contained in:
@@ -289,7 +289,7 @@ func (s *fakeImageService) LocalResolve(refOrID string) (imagestore.Image, error
|
||||
|
||||
func (s *fakeImageService) ImageFSPaths() map[string]string { return make(map[string]string) }
|
||||
|
||||
func (s *fakeImageService) PullImage(context.Context, string, func(string) (string, string, error), *runtime.PodSandboxConfig) (string, error) {
|
||||
func (s *fakeImageService) PullImage(context.Context, string, func(string) (string, string, error), *runtime.PodSandboxConfig, string) (string, error) {
|
||||
return "", errors.New("not implemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -108,15 +108,14 @@ func (c *GRPCCRIImageService) PullImage(ctx context.Context, r *runtime.PullImag
|
||||
return ParseAuth(hostauth, host)
|
||||
}
|
||||
|
||||
ref, err := c.CRIImageService.PullImage(ctx, imageRef, credentials, r.SandboxConfig)
|
||||
ref, err := c.CRIImageService.PullImage(ctx, imageRef, credentials, r.SandboxConfig, r.GetImage().GetRuntimeHandler())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &runtime.PullImageResponse{ImageRef: ref}, nil
|
||||
}
|
||||
|
||||
func (c *CRIImageService) PullImage(ctx context.Context, name string, credentials func(string) (string, string, error), sandboxConfig *runtime.PodSandboxConfig) (_ string, err error) {
|
||||
|
||||
func (c *CRIImageService) PullImage(ctx context.Context, name string, credentials func(string) (string, string, error), sandboxConfig *runtime.PodSandboxConfig, runtimeHandler string) (_ string, err error) {
|
||||
span := tracing.SpanFromContext(ctx)
|
||||
defer func() {
|
||||
// TODO: add domain label for imagePulls metrics, and we may need to provide a mechanism
|
||||
@@ -770,6 +769,8 @@ func (c *CRIImageService) snapshotterFromPodSandboxConfig(ctx context.Context, i
|
||||
return snapshotter, nil
|
||||
}
|
||||
|
||||
// TODO(kiashok): honor the new CRI runtime handler field added to v0.29.0
|
||||
// for image pull per runtime class support.
|
||||
runtimeHandler, ok := s.Annotations[annotations.RuntimeHandler]
|
||||
if !ok {
|
||||
return snapshotter, nil
|
||||
|
||||
@@ -107,7 +107,7 @@ type RuntimeService interface {
|
||||
type ImageService interface {
|
||||
LocalResolve(refOrID string) (imagestore.Image, error)
|
||||
GetImage(id string) (imagestore.Image, error)
|
||||
PullImage(ctx context.Context, name string, creds func(string) (string, string, error), sc *runtime.PodSandboxConfig) (string, error)
|
||||
PullImage(ctx context.Context, name string, creds func(string) (string, string, error), sc *runtime.PodSandboxConfig, runtimeHandler string) (string, error)
|
||||
RuntimeSnapshotter(ctx context.Context, ociRuntime criconfig.Runtime) string
|
||||
PinnedImage(string) string
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func (c *Controller) Start(ctx context.Context, id string) (cin sandbox.Controll
|
||||
sandboxImage = criconfig.DefaultSandboxImage
|
||||
}
|
||||
// Ensure sandbox container image snapshot.
|
||||
image, err := c.ensureImageExists(ctx, sandboxImage, config)
|
||||
image, err := c.ensureImageExists(ctx, sandboxImage, config, metadata.RuntimeHandler)
|
||||
if err != nil {
|
||||
return cin, fmt.Errorf("failed to get sandbox image %q: %w", sandboxImage, err)
|
||||
}
|
||||
@@ -293,7 +293,7 @@ func (c *Controller) Create(_ctx context.Context, info sandbox.Sandbox, opts ...
|
||||
return c.store.Save(podSandbox)
|
||||
}
|
||||
|
||||
func (c *Controller) ensureImageExists(ctx context.Context, ref string, config *runtime.PodSandboxConfig) (*imagestore.Image, error) {
|
||||
func (c *Controller) ensureImageExists(ctx context.Context, ref string, config *runtime.PodSandboxConfig, runtimeHandler string) (*imagestore.Image, error) {
|
||||
image, err := c.imageService.LocalResolve(ref)
|
||||
if err != nil && !errdefs.IsNotFound(err) {
|
||||
return nil, fmt.Errorf("failed to get image %q: %w", ref, err)
|
||||
@@ -303,7 +303,7 @@ func (c *Controller) ensureImageExists(ctx context.Context, ref string, config *
|
||||
}
|
||||
// Pull image to ensure the image exists
|
||||
// TODO: Cleaner interface
|
||||
imageID, err := c.imageService.PullImage(ctx, ref, nil, config)
|
||||
imageID, err := c.imageService.PullImage(ctx, ref, nil, config, runtimeHandler)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to pull image %q: %w", ref, err)
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ type RuntimeService interface {
|
||||
type ImageService interface {
|
||||
RuntimeSnapshotter(ctx context.Context, ociRuntime criconfig.Runtime) string
|
||||
|
||||
PullImage(ctx context.Context, name string, credentials func(string) (string, string, error), sandboxConfig *runtime.PodSandboxConfig) (string, error)
|
||||
PullImage(ctx context.Context, name string, credentials func(string) (string, string, error), sandboxConfig *runtime.PodSandboxConfig, runtimeHandler string) (string, error)
|
||||
UpdateImage(ctx context.Context, r string) error
|
||||
|
||||
CheckImages(ctx context.Context) error
|
||||
|
||||
Reference in New Issue
Block a user