Move cri base plugin to CRI runtime service
Create new plugin type for CRI runtime and image services. Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
@@ -65,6 +65,15 @@ type sandboxService interface {
|
||||
SandboxController(config *runtime.PodSandboxConfig, runtimeHandler string) (sandbox.Controller, error)
|
||||
}
|
||||
|
||||
// RuntimeService specifies dependencies to runtime service which provides
|
||||
// the runtime configuration and OCI spec loading.
|
||||
type RuntimeService interface {
|
||||
Config() criconfig.Config
|
||||
|
||||
// LoadCISpec loads cached OCI specs via `Runtime.BaseRuntimeSpec`
|
||||
LoadOCISpec(string) (*oci.Spec, error)
|
||||
}
|
||||
|
||||
// ImageService specifies dependencies to image service.
|
||||
type ImageService interface {
|
||||
RuntimeSnapshotter(ctx context.Context, ociRuntime criconfig.Runtime) string
|
||||
@@ -84,6 +93,7 @@ type ImageService interface {
|
||||
|
||||
// criService implements CRIService.
|
||||
type criService struct {
|
||||
RuntimeService
|
||||
ImageService
|
||||
// config contains all configurations.
|
||||
config criconfig.Config
|
||||
@@ -115,8 +125,6 @@ type criService struct {
|
||||
// cniNetConfMonitor is used to reload cni network conf if there is
|
||||
// any valid fs change events from cni network conf dir.
|
||||
cniNetConfMonitor map[string]*cniNetConfSyncer
|
||||
// baseOCISpecs contains cached OCI specs loaded via `Runtime.BaseRuntimeSpec`
|
||||
baseOCISpecs map[string]*oci.Spec
|
||||
// allCaps is the list of the capabilities.
|
||||
// When nil, parsed from CapEff of /proc/self/status.
|
||||
allCaps []string //nolint:nolintlint,unused // Ignore on non-Linux
|
||||
@@ -130,6 +138,8 @@ type criService struct {
|
||||
}
|
||||
|
||||
type CRIServiceOptions struct {
|
||||
RuntimeService RuntimeService
|
||||
|
||||
ImageService ImageService
|
||||
|
||||
NRI *nri.API
|
||||
@@ -137,9 +147,6 @@ type CRIServiceOptions struct {
|
||||
// SandboxControllers is a map of all the loaded sandbox controllers
|
||||
SandboxControllers map[string]sandbox.Controller
|
||||
|
||||
// BaseOCISpecs contains cached OCI specs loaded via `Runtime.BaseRuntimeSpec`
|
||||
BaseOCISpecs map[string]*oci.Spec
|
||||
|
||||
// Client is the base containerd client used for accessing services,
|
||||
//
|
||||
// TODO: Replace this gradually with directly configured instances
|
||||
@@ -147,18 +154,18 @@ type CRIServiceOptions struct {
|
||||
}
|
||||
|
||||
// NewCRIService returns a new instance of CRIService
|
||||
// TODO: Add criBase.BaseOCISpecs to options
|
||||
func NewCRIService(config criconfig.Config, options *CRIServiceOptions) (CRIService, runtime.RuntimeServiceServer, error) {
|
||||
func NewCRIService(options *CRIServiceOptions) (CRIService, runtime.RuntimeServiceServer, error) {
|
||||
var err error
|
||||
labels := label.NewStore()
|
||||
config := options.RuntimeService.Config()
|
||||
|
||||
c := &criService{
|
||||
RuntimeService: options.RuntimeService,
|
||||
ImageService: options.ImageService,
|
||||
config: config,
|
||||
client: options.Client,
|
||||
imageFSPaths: options.ImageService.ImageFSPaths(),
|
||||
os: osinterface.RealOS{},
|
||||
baseOCISpecs: options.BaseOCISpecs,
|
||||
sandboxStore: sandboxstore.NewStore(labels),
|
||||
containerStore: containerstore.NewStore(labels),
|
||||
sandboxNameIndex: registrar.NewRegistrar(),
|
||||
|
||||
Reference in New Issue
Block a user