pkg/cri: split out NRI API from pkg/cri/server.
Split out the criService-agnostic bits of nri-api* from pkg/cri/server to pkg/cri/nri to allow sharing a single implementation betwen the server and sbserver versions. Rework the interfaces to not require access to package internals. Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
This commit is contained in:
@@ -29,9 +29,9 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/oci"
|
||||
"github.com/containerd/containerd/pkg/cri/instrument"
|
||||
"github.com/containerd/containerd/pkg/cri/nri"
|
||||
"github.com/containerd/containerd/pkg/cri/streaming"
|
||||
"github.com/containerd/containerd/pkg/kmutex"
|
||||
"github.com/containerd/containerd/pkg/nri"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
cni "github.com/containerd/go-cni"
|
||||
@@ -112,15 +112,15 @@ type criService struct {
|
||||
// one in-flight fetch request or unpack handler for a given descriptor's
|
||||
// or chain ID.
|
||||
unpackDuplicationSuppressor kmutex.KeyedLocker
|
||||
|
||||
nri *nriAPI
|
||||
// nri is used to hook NRI into CRI request processing.
|
||||
nri *nri.API
|
||||
// containerEventsChan is used to capture container events and send them
|
||||
// to the caller of GetContainerEvents.
|
||||
containerEventsChan chan runtime.ContainerEventResponse
|
||||
}
|
||||
|
||||
// NewCRIService returns a new instance of CRIService
|
||||
func NewCRIService(config criconfig.Config, client *containerd.Client, nrip nri.API) (CRIService, error) {
|
||||
func NewCRIService(config criconfig.Config, client *containerd.Client, nri *nri.API) (CRIService, error) {
|
||||
var err error
|
||||
labels := label.NewStore()
|
||||
c := &criService{
|
||||
@@ -183,12 +183,7 @@ func NewCRIService(config criconfig.Config, client *containerd.Client, nrip nri.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if nrip != nil {
|
||||
c.nri = &nriAPI{
|
||||
cri: c,
|
||||
nri: nrip,
|
||||
}
|
||||
}
|
||||
c.nri = nri
|
||||
|
||||
return c, nil
|
||||
}
|
||||
@@ -258,7 +253,10 @@ func (c *criService) Run() error {
|
||||
}
|
||||
}()
|
||||
|
||||
c.nri.register()
|
||||
// register CRI domain with NRI
|
||||
if err := c.nri.Register(&criImplementation{c}); err != nil {
|
||||
return fmt.Errorf("failed to set up NRI for CRI service: %w", err)
|
||||
}
|
||||
|
||||
// Set the server as initialized. GRPC services could start serving traffic.
|
||||
c.initialized.Set()
|
||||
@@ -292,6 +290,7 @@ func (c *criService) Run() error {
|
||||
if cniNetConfMonitorErr != nil {
|
||||
return fmt.Errorf("cni network conf monitor error: %w", cniNetConfMonitorErr)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user