Split CRI image service from GRPC handler
Prepares the CRI image service for splitting CRI into multiple plugins. Also prepares for config migration which will spread across multiple different plugins. Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
		| @@ -20,12 +20,14 @@ package fuzz | ||||
|  | ||||
| import ( | ||||
| 	fuzz "github.com/AdaLogics/go-fuzz-headers" | ||||
| 	"google.golang.org/grpc" | ||||
| 	runtime "k8s.io/cri-api/pkg/apis/runtime/v1" | ||||
|  | ||||
| 	containerd "github.com/containerd/containerd/v2/client" | ||||
| 	"github.com/containerd/containerd/v2/oci" | ||||
| 	criconfig "github.com/containerd/containerd/v2/pkg/cri/config" | ||||
| 	"github.com/containerd/containerd/v2/pkg/cri/instrument" | ||||
| 	"github.com/containerd/containerd/v2/pkg/cri/server" | ||||
| 	"github.com/containerd/containerd/v2/pkg/cri/server/base" | ||||
| 	"github.com/containerd/containerd/v2/pkg/cri/server/images" | ||||
| ) | ||||
|  | ||||
| @@ -42,20 +44,38 @@ func FuzzCRIServer(data []byte) int { | ||||
|  | ||||
| 	config := criconfig.Config{} | ||||
|  | ||||
| 	criBase := &base.CRIBase{ | ||||
| 		Config:       config, | ||||
| 	imageService, err := images.NewService(config, map[string]string{}, client) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
|  | ||||
| 	is := images.NewGRPCService(imageService) | ||||
|  | ||||
| 	c, rs, err := server.NewCRIService(config, &server.CRIServiceOptions{ | ||||
| 		ImageService: imageService, | ||||
| 		Client:       client, | ||||
| 		BaseOCISpecs: map[string]*oci.Spec{}, | ||||
| 	} | ||||
|  | ||||
| 	imageService, err := images.NewService(config, client) | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
|  | ||||
| 	c, err := server.NewCRIService(criBase, imageService, client, nil) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
|  | ||||
| 	return fuzzCRI(f, c) | ||||
| 	return fuzzCRI(f, &service{ | ||||
| 		CRIService:           c, | ||||
| 		RuntimeServiceServer: rs, | ||||
| 		ImageServiceServer:   is, | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| type service struct { | ||||
| 	server.CRIService | ||||
| 	runtime.RuntimeServiceServer | ||||
| 	runtime.ImageServiceServer | ||||
| } | ||||
|  | ||||
| func (c *service) Register(s *grpc.Server) error { | ||||
| 	instrumented := instrument.NewService(c) | ||||
| 	runtime.RegisterRuntimeServiceServer(s, instrumented) | ||||
| 	runtime.RegisterImageServiceServer(s, instrumented) | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Derek McGowan
					Derek McGowan