Move shim protos into linux pkg
This moves the shim's API and protos out of the containerd services package and into the linux runtime package. This is because the shim is an implementation detail of the linux runtime that we have and it is not a containerd user facing api. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
@@ -13,8 +14,8 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
shimapi "github.com/containerd/containerd/api/services/shim/v1"
|
||||
"github.com/containerd/containerd/linux/shim"
|
||||
shimapi "github.com/containerd/containerd/linux/shim/v1"
|
||||
"github.com/containerd/containerd/reaper"
|
||||
"github.com/containerd/containerd/version"
|
||||
"github.com/urfave/cli"
|
||||
@@ -66,7 +67,7 @@ func main() {
|
||||
return err
|
||||
}
|
||||
server := grpc.NewServer()
|
||||
sv, err := shim.New(path, context.GlobalString("namespace"))
|
||||
sv, err := shim.NewService(path, context.GlobalString("namespace"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -114,7 +115,24 @@ func handleSignals(signals chan os.Signal, server *grpc.Server) error {
|
||||
// i.e. machine reboot
|
||||
server.Stop()
|
||||
return nil
|
||||
case unix.SIGUSR1:
|
||||
dumpStacks()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func dumpStacks() {
|
||||
var (
|
||||
buf []byte
|
||||
stackSize int
|
||||
)
|
||||
bufferLen := 16384
|
||||
for stackSize == len(buf) {
|
||||
buf = make([]byte, bufferLen)
|
||||
stackSize = runtime.Stack(buf, true)
|
||||
bufferLen *= 2
|
||||
}
|
||||
buf = buf[:stackSize]
|
||||
logrus.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf)
|
||||
}
|
||||
|
||||
@@ -19,13 +19,16 @@ import (
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/containerd/console"
|
||||
"github.com/containerd/containerd/api/services/shim/v1"
|
||||
shim "github.com/containerd/containerd/linux/shim/v1"
|
||||
protobuf "github.com/gogo/protobuf/types"
|
||||
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var empty = &google_protobuf.Empty{}
|
||||
|
||||
var fifoFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "stdin",
|
||||
@@ -94,7 +97,7 @@ var shimCreateCommand = cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r, err := service.Create(ctx, &shim.CreateRequest{
|
||||
r, err := service.Create(ctx, &shim.CreateTaskRequest{
|
||||
ID: id,
|
||||
Bundle: context.String("bundle"),
|
||||
Runtime: context.String("runtime"),
|
||||
@@ -118,7 +121,7 @@ var shimCreateCommand = cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := service.Pty(ctx, &shim.PtyRequest{
|
||||
if _, err := service.ResizePty(ctx, &shim.ResizePtyRequest{
|
||||
Pid: r.Pid,
|
||||
Width: uint32(size.Width),
|
||||
Height: uint32(size.Height),
|
||||
@@ -140,7 +143,7 @@ var shimStartCommand = cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = service.Start(gocontext.Background(), &shim.StartRequest{})
|
||||
_, err = service.Start(gocontext.Background(), empty)
|
||||
return err
|
||||
},
|
||||
}
|
||||
@@ -153,7 +156,7 @@ var shimDeleteCommand = cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r, err := service.Delete(gocontext.Background(), &shim.DeleteRequest{})
|
||||
r, err := service.Delete(gocontext.Background(), empty)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -170,7 +173,7 @@ var shimStateCommand = cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r, err := service.State(gocontext.Background(), &shim.StateRequest{})
|
||||
r, err := service.State(gocontext.Background(), empty)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -227,7 +230,7 @@ var shimExecCommand = cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
rq := &shim.ExecRequest{
|
||||
rq := &shim.ExecProcessRequest{
|
||||
Spec: &protobuf.Any{
|
||||
TypeUrl: specs.Version,
|
||||
Value: spec,
|
||||
@@ -254,7 +257,7 @@ var shimExecCommand = cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := service.Pty(ctx, &shim.PtyRequest{
|
||||
if _, err := service.ResizePty(ctx, &shim.ResizePtyRequest{
|
||||
Pid: r.Pid,
|
||||
Width: uint32(size.Width),
|
||||
Height: uint32(size.Height),
|
||||
@@ -276,7 +279,7 @@ var shimEventsCommand = cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
events, err := service.Events(gocontext.Background(), &shim.EventsRequest{})
|
||||
events, err := service.Stream(gocontext.Background(), &shim.StreamEventsRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user