Extract CRI instrument package

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko
2023-02-12 20:49:15 -08:00
parent cf7b705dcd
commit 750d18aced
6 changed files with 66 additions and 1751 deletions

View File

@@ -94,9 +94,6 @@ const (
// runtimeRunhcsV1 is the runtime type for runhcs.
runtimeRunhcsV1 = "io.containerd.runhcs.v1"
// name prefix for CRI server specific spans
criSpanPrefix = "pkg.cri.server"
)
// makeSandboxName generates sandbox name from sandbox metadata. The name

File diff suppressed because it is too large Load Diff

View File

@@ -28,6 +28,7 @@ import (
"github.com/containerd/containerd"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/pkg/cri/instrument"
"github.com/containerd/containerd/pkg/cri/streaming"
"github.com/containerd/containerd/pkg/kmutex"
"github.com/containerd/containerd/pkg/nri"
@@ -54,25 +55,16 @@ import (
// defaultNetworkPlugin is used for the default CNI configuration
const defaultNetworkPlugin = "default"
// grpcServices are all the grpc services provided by cri containerd.
type grpcServices interface {
runtime.RuntimeServiceServer
runtime.ImageServiceServer
}
type grpcAlphaServices interface {
runtime_alpha.RuntimeServiceServer
runtime_alpha.ImageServiceServer
}
// CRIService is the interface implement CRI remote service server.
type CRIService interface {
runtime.RuntimeServiceServer
runtime.ImageServiceServer
// Closer is used by containerd to gracefully stop cri service.
io.Closer
Run() error
// io.Closer is used by containerd to gracefully stop cri service.
io.Closer
Register(*grpc.Server) error
grpcServices
}
// criService implements CRIService.
@@ -319,13 +311,20 @@ func (c *criService) Close() error {
return nil
}
// IsInitialized indicates whether CRI service has finished initialization.
func (c *criService) IsInitialized() bool {
return c.initialized.IsSet()
}
func (c *criService) register(s *grpc.Server) error {
instrumented := newInstrumentedService(c)
instrumented := instrument.NewService(c)
runtime.RegisterRuntimeServiceServer(s, instrumented)
runtime.RegisterImageServiceServer(s, instrumented)
instrumentedAlpha := newInstrumentedAlphaService(c)
instrumentedAlpha := instrument.NewAlphaService(c)
runtime_alpha.RegisterRuntimeServiceServer(s, instrumentedAlpha)
runtime_alpha.RegisterImageServiceServer(s, instrumentedAlpha)
return nil
}