Refactor runtime code for code sharing
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -37,8 +37,9 @@ import (
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
rproc "github.com/containerd/containerd/runtime/proc"
|
||||
"github.com/containerd/containerd/runtime/v1/linux/proc"
|
||||
"github.com/containerd/containerd/pkg/oom"
|
||||
"github.com/containerd/containerd/pkg/process"
|
||||
"github.com/containerd/containerd/pkg/stdio"
|
||||
"github.com/containerd/containerd/runtime/v2/runc"
|
||||
"github.com/containerd/containerd/runtime/v2/runc/options"
|
||||
"github.com/containerd/containerd/runtime/v2/shim"
|
||||
@@ -73,7 +74,7 @@ type spec struct {
|
||||
|
||||
// New returns a new shim service that can be used via GRPC
|
||||
func New(ctx context.Context, id string, publisher shim.Publisher, shutdown func()) (shim.Shim, error) {
|
||||
ep, err := runc.NewOOMEpoller(publisher)
|
||||
ep, err := oom.New(publisher)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -104,9 +105,9 @@ type service struct {
|
||||
|
||||
context context.Context
|
||||
events chan interface{}
|
||||
platform rproc.Platform
|
||||
platform stdio.Platform
|
||||
ec chan runcC.Exit
|
||||
ep *runc.Epoller
|
||||
ep *oom.Epoller
|
||||
|
||||
// id only used in cleanup case
|
||||
id string
|
||||
@@ -254,7 +255,7 @@ func (s *service) Cleanup(ctx context.Context) (*taskAPI.DeleteResponse, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r := proc.NewRunc(proc.RuncRoot, path, ns, runtime, "", false)
|
||||
r := process.NewRunc(process.RuncRoot, path, ns, runtime, "", false)
|
||||
if err := r.Delete(ctx, s.id, &runcC.DeleteOpts{
|
||||
Force: true,
|
||||
}); err != nil {
|
||||
@@ -653,7 +654,7 @@ func (s *service) checkProcesses(e runcC.Exit) {
|
||||
for _, p := range container.All() {
|
||||
if p.Pid() == e.Pid {
|
||||
if shouldKillAll {
|
||||
if ip, ok := p.(*proc.Init); ok {
|
||||
if ip, ok := p.(*process.Init); ok {
|
||||
// Ensure all children are killed
|
||||
if err := ip.KillAll(s.context); err != nil {
|
||||
logrus.WithError(err).WithField("id", ip.ID()).
|
||||
@@ -705,7 +706,7 @@ func (s *service) getContainerPids(ctx context.Context, id string) ([]uint32, er
|
||||
if err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
}
|
||||
ps, err := p.(*proc.Init).Runtime().Ps(ctx, id)
|
||||
ps, err := p.(*process.Init).Runtime().Ps(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user