Skip to content

Commit f1a3c37

Browse files
authored
Merge pull request containerd#9815 from kiashok/updateCRIServicePull
Pass runtimehandler from CRI to pull image request
2 parents 97f86f1 + 4c775fc commit f1a3c37

File tree

10 files changed

+20
-19
lines changed

10 files changed

+20
-19
lines changed

integration/cri-api/pkg/apis/services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ type ImageManagerService interface {
140140
// ImageStatus returns the status of the image.
141141
ImageStatus(image *runtimeapi.ImageSpec, opts ...grpc.CallOption) (*runtimeapi.Image, error)
142142
// PullImage pulls an image with the authentication config.
143-
PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig, opts ...grpc.CallOption) (string, error)
143+
PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig, runtimeHandler string, opts ...grpc.CallOption) (string, error)
144144
// RemoveImage removes the image.
145145
RemoveImage(image *runtimeapi.ImageSpec, opts ...grpc.CallOption) error
146146
// ImageFsInfo returns information of the filesystem that is used to store images.

integration/image_pull_timeout_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func testCRIImagePullTimeoutBySlowCommitWriter(t *testing.T) {
9292

9393
ctx := namespaces.WithNamespace(logtest.WithT(context.Background(), t), k8sNamespace)
9494

95-
_, err = criService.PullImage(ctx, pullProgressTestImageName, nil, nil)
95+
_, err = criService.PullImage(ctx, pullProgressTestImageName, nil, nil, "")
9696
assert.NoError(t, err)
9797
}
9898

@@ -211,7 +211,7 @@ func testCRIImagePullTimeoutByHoldingContentOpenWriter(t *testing.T) {
211211
go func() {
212212
defer close(errCh)
213213

214-
_, err := criService.PullImage(ctx, pullProgressTestImageName, nil, nil)
214+
_, err := criService.PullImage(ctx, pullProgressTestImageName, nil, nil, "")
215215
errCh <- err
216216
}()
217217

@@ -294,7 +294,7 @@ func testCRIImagePullTimeoutByNoDataTransferred(t *testing.T) {
294294
dctx, _, err := cli.WithLease(ctx)
295295
assert.NoError(t, err)
296296

297-
_, err = criService.PullImage(dctx, fmt.Sprintf("%s/%s", mirrorURL.Host, "containerd/volume-ownership:2.1"), nil, nil)
297+
_, err = criService.PullImage(dctx, fmt.Sprintf("%s/%s", mirrorURL.Host, "containerd/volume-ownership:2.1"), nil, nil, "")
298298

299299
assert.Equal(t, context.Canceled, errors.Unwrap(err), "[%v] expected canceled error, but got (%v)", idx, err)
300300
assert.True(t, mirrorSrv.limiter.clearHitCircuitBreaker(), "[%v] expected to hit circuit breaker", idx)

integration/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ func EnsureImageExists(t *testing.T, imageName string) string {
735735
}
736736

737737
t.Logf("Pull test image %q", imageName)
738-
imgID, err := imageService.PullImage(&runtime.ImageSpec{Image: imageName}, nil, nil)
738+
imgID, err := imageService.PullImage(&runtime.ImageSpec{Image: imageName}, nil, nil, "")
739739
require.NoError(t, err)
740740

741741
return imgID

integration/release_upgrade_linux_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func shouldRecoverAllThePodsAfterUpgrade(t *testing.T, criRuntimeService cri.Run
116116
var busyboxImage = images.Get(images.BusyBox)
117117

118118
t.Logf("Pulling image %q", busyboxImage)
119-
_, err := criImageService.PullImage(&criruntime.ImageSpec{Image: busyboxImage}, nil, nil)
119+
_, err := criImageService.PullImage(&criruntime.ImageSpec{Image: busyboxImage}, nil, nil, "")
120120
require.NoError(t, err)
121121

122122
t.Log("Create first sandbox")
@@ -195,7 +195,7 @@ func execToExistingContainer(t *testing.T, criRuntimeService cri.RuntimeService,
195195
var busyboxImage = images.Get(images.BusyBox)
196196

197197
t.Logf("Pulling image %q", busyboxImage)
198-
_, err := criImageService.PullImage(&criruntime.ImageSpec{Image: busyboxImage}, nil, nil)
198+
_, err := criImageService.PullImage(&criruntime.ImageSpec{Image: busyboxImage}, nil, nil, "")
199199
require.NoError(t, err)
200200
t.Log("Create sandbox")
201201
sbConfig := PodSandboxConfig("sandbox", "running")
@@ -263,7 +263,7 @@ func shouldManipulateContainersInPodAfterUpgrade(t *testing.T, criRuntimeService
263263
var busyboxImage = images.Get(images.BusyBox)
264264

265265
t.Logf("Pulling image %q", busyboxImage)
266-
_, err := criImageService.PullImage(&criruntime.ImageSpec{Image: busyboxImage}, nil, nil)
266+
_, err := criImageService.PullImage(&criruntime.ImageSpec{Image: busyboxImage}, nil, nil, "")
267267
require.NoError(t, err)
268268

269269
t.Log("Create a sandbox")
@@ -353,7 +353,7 @@ func shouldRecoverExistingImages(t *testing.T, criRuntimeService cri.RuntimeServ
353353
expectedRefs := []string{}
354354
for _, img := range images {
355355
t.Logf("Pulling image %q", img)
356-
imgRef, err := criImageService.PullImage(&criruntime.ImageSpec{Image: img}, nil, nil)
356+
imgRef, err := criImageService.PullImage(&criruntime.ImageSpec{Image: img}, nil, nil, "")
357357
require.NoError(t, err)
358358
expectedRefs = append(expectedRefs, imgRef)
359359
}

integration/remote/remote_image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (r *ImageService) ImageStatus(image *runtimeapi.ImageSpec, opts ...grpc.Cal
122122
}
123123

124124
// PullImage pulls an image with authentication config.
125-
func (r *ImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig, opts ...grpc.CallOption) (string, error) {
125+
func (r *ImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig, runtimeHandler string, opts ...grpc.CallOption) (string, error) {
126126
ctx, cancel := getContextWithCancel()
127127
defer cancel()
128128

internal/cri/server/container_status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (s *fakeImageService) LocalResolve(refOrID string) (imagestore.Image, error
289289

290290
func (s *fakeImageService) ImageFSPaths() map[string]string { return make(map[string]string) }
291291

292-
func (s *fakeImageService) PullImage(context.Context, string, func(string) (string, string, error), *runtime.PodSandboxConfig) (string, error) {
292+
func (s *fakeImageService) PullImage(context.Context, string, func(string) (string, string, error), *runtime.PodSandboxConfig, string) (string, error) {
293293
return "", errors.New("not implemented")
294294
}
295295

internal/cri/server/images/image_pull.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,14 @@ func (c *GRPCCRIImageService) PullImage(ctx context.Context, r *runtime.PullImag
108108
return ParseAuth(hostauth, host)
109109
}
110110

111-
ref, err := c.CRIImageService.PullImage(ctx, imageRef, credentials, r.SandboxConfig)
111+
ref, err := c.CRIImageService.PullImage(ctx, imageRef, credentials, r.SandboxConfig, r.GetImage().GetRuntimeHandler())
112112
if err != nil {
113113
return nil, err
114114
}
115115
return &runtime.PullImageResponse{ImageRef: ref}, nil
116116
}
117117

118-
func (c *CRIImageService) PullImage(ctx context.Context, name string, credentials func(string) (string, string, error), sandboxConfig *runtime.PodSandboxConfig) (_ string, err error) {
119-
118+
func (c *CRIImageService) PullImage(ctx context.Context, name string, credentials func(string) (string, string, error), sandboxConfig *runtime.PodSandboxConfig, runtimeHandler string) (_ string, err error) {
120119
span := tracing.SpanFromContext(ctx)
121120
defer func() {
122121
// 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
770769
return snapshotter, nil
771770
}
772771

772+
// TODO(kiashok): honor the new CRI runtime handler field added to v0.29.0
773+
// for image pull per runtime class support.
773774
runtimeHandler, ok := s.Annotations[annotations.RuntimeHandler]
774775
if !ok {
775776
return snapshotter, nil

internal/cri/server/podsandbox/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ type RuntimeService interface {
107107
type ImageService interface {
108108
LocalResolve(refOrID string) (imagestore.Image, error)
109109
GetImage(id string) (imagestore.Image, error)
110-
PullImage(ctx context.Context, name string, creds func(string) (string, string, error), sc *runtime.PodSandboxConfig) (string, error)
110+
PullImage(ctx context.Context, name string, creds func(string) (string, string, error), sc *runtime.PodSandboxConfig, runtimeHandler string) (string, error)
111111
RuntimeSnapshotter(ctx context.Context, ociRuntime criconfig.Runtime) string
112112
PinnedImage(string) string
113113
}

internal/cri/server/podsandbox/sandbox_run.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (c *Controller) Start(ctx context.Context, id string) (cin sandbox.Controll
8080
sandboxImage = criconfig.DefaultSandboxImage
8181
}
8282
// Ensure sandbox container image snapshot.
83-
image, err := c.ensureImageExists(ctx, sandboxImage, config)
83+
image, err := c.ensureImageExists(ctx, sandboxImage, config, metadata.RuntimeHandler)
8484
if err != nil {
8585
return cin, fmt.Errorf("failed to get sandbox image %q: %w", sandboxImage, err)
8686
}
@@ -293,7 +293,7 @@ func (c *Controller) Create(_ctx context.Context, info sandbox.Sandbox, opts ...
293293
return c.store.Save(podSandbox)
294294
}
295295

296-
func (c *Controller) ensureImageExists(ctx context.Context, ref string, config *runtime.PodSandboxConfig) (*imagestore.Image, error) {
296+
func (c *Controller) ensureImageExists(ctx context.Context, ref string, config *runtime.PodSandboxConfig, runtimeHandler string) (*imagestore.Image, error) {
297297
image, err := c.imageService.LocalResolve(ref)
298298
if err != nil && !errdefs.IsNotFound(err) {
299299
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 *
303303
}
304304
// Pull image to ensure the image exists
305305
// TODO: Cleaner interface
306-
imageID, err := c.imageService.PullImage(ctx, ref, nil, config)
306+
imageID, err := c.imageService.PullImage(ctx, ref, nil, config, runtimeHandler)
307307
if err != nil {
308308
return nil, fmt.Errorf("failed to pull image %q: %w", ref, err)
309309
}

internal/cri/server/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ type RuntimeService interface {
7878
type ImageService interface {
7979
RuntimeSnapshotter(ctx context.Context, ociRuntime criconfig.Runtime) string
8080

81-
PullImage(ctx context.Context, name string, credentials func(string) (string, string, error), sandboxConfig *runtime.PodSandboxConfig) (string, error)
81+
PullImage(ctx context.Context, name string, credentials func(string) (string, string, error), sandboxConfig *runtime.PodSandboxConfig, runtimeHandler string) (string, error)
8282
UpdateImage(ctx context.Context, r string) error
8383

8484
CheckImages(ctx context.Context) error

0 commit comments

Comments
 (0)