Add Exec IDs

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-06-28 12:54:10 -07:00
parent e283b3802d
commit f93bfb6233
36 changed files with 1441 additions and 2055 deletions

View File

@@ -63,7 +63,7 @@ func getEventOutput(env *eventsapi.Envelope) (string, error) {
}
switch e := v.(type) {
case *eventsapi.ContainerCreate:
out = fmt.Sprintf("id=%s image=%s runtime=%s", e.ContainerID, e.Image, e.Runtime)
out = fmt.Sprintf("id=%s image=%s runtime=%s", e.ID, e.Image, e.Runtime)
case *eventsapi.TaskCreate:
out = "id=" + e.ContainerID
case *eventsapi.TaskStart:
@@ -71,9 +71,9 @@ func getEventOutput(env *eventsapi.Envelope) (string, error) {
case *eventsapi.TaskDelete:
out = fmt.Sprintf("id=%s pid=%d status=%d", e.ContainerID, e.Pid, e.ExitStatus)
case *eventsapi.ContainerUpdate:
out = "id=" + e.ContainerID
out = "id=" + e.ID
case *eventsapi.ContainerDelete:
out = "id=" + e.ContainerID
out = "id=" + e.ID
case *eventsapi.SnapshotPrepare:
out = fmt.Sprintf("key=%s parent=%s", e.Key, e.Parent)
case *eventsapi.SnapshotCommit:
@@ -95,11 +95,11 @@ func getEventOutput(env *eventsapi.Envelope) (string, error) {
for _, m := range e.RootFS {
mounts = append(mounts, fmt.Sprintf("type=%s:src=%s", m.Type, m.Source))
}
out = fmt.Sprintf("id=%s bundle=%s rootfs=%s checkpoint=%s", e.ID, e.Bundle, strings.Join(mounts, ","), e.Checkpoint)
out = fmt.Sprintf("id=%s bundle=%s rootfs=%s checkpoint=%s", e.ContainerID, e.Bundle, strings.Join(mounts, ","), e.Checkpoint)
case *eventsapi.RuntimeEvent:
out = fmt.Sprintf("id=%s type=%s pid=%d status=%d exited=%s", e.ID, e.Type, e.Pid, e.ExitStatus, e.ExitedAt)
out = fmt.Sprintf("id=%s container_id=%s type=%s pid=%d status=%d exited=%s", e.ID, e.ContainerID, e.Type, e.Pid, e.ExitStatus, e.ExitedAt)
case *eventsapi.RuntimeDelete:
out = fmt.Sprintf("id=%s runtime=%s status=%d exited=%s", e.ID, e.Runtime, e.ExitStatus, e.ExitedAt)
out = fmt.Sprintf("id=%s runtime=%s status=%d exited=%s", e.ContainerID, e.Runtime, e.ExitStatus, e.ExitedAt)
default:
out = env.Event.TypeUrl
}

View File

@@ -22,6 +22,10 @@ var execCommand = cli.Command{
Name: "tty,t",
Usage: "allocate a TTY for the container",
},
cli.StringFlag{
Name: "exec-id",
Usage: "exec specific id for the process",
},
},
Action: func(context *cli.Context) error {
var (
@@ -60,7 +64,7 @@ var execCommand = cli.Command{
if tty {
io = containerd.StdioTerminal
}
process, err := task.Exec(ctx, pspec, io)
process, err := task.Exec(ctx, context.String("exec-id"), pspec, io)
if err != nil {
return err
}

View File

@@ -36,7 +36,7 @@ var psCommand = cli.Command{
if err != nil {
return err
}
processes, err := task.Processes(ctx)
processes, err := task.Pids(ctx)
if err != nil {
return err
}

View File

@@ -129,7 +129,7 @@ var shimCreateCommand = cli.Command{
return err
}
if _, err := service.ResizePty(ctx, &shim.ResizePtyRequest{
Pid: r.Pid,
ID: id,
Width: uint32(size.Width),
Height: uint32(size.Height),
}); err != nil {
@@ -180,7 +180,9 @@ var shimStateCommand = cli.Command{
if err != nil {
return err
}
r, err := service.State(gocontext.Background(), empty)
r, err := service.State(gocontext.Background(), &shim.StateRequest{
ID: context.Args().First(),
})
if err != nil {
return err
}
@@ -221,10 +223,18 @@ var shimExecCommand = cli.Command{
),
Action: func(context *cli.Context) error {
service, err := getShimService(context)
ctx := gocontext.Background()
if err != nil {
return err
}
var (
id = context.Args().First()
ctx = gocontext.Background()
)
if id == "" {
return errors.New("exec id must be provided")
}
tty := context.Bool("tty")
wg, err := prepareStdio(context.String("stdin"), context.String("stdout"), context.String("stderr"), tty)
if err != nil {
@@ -242,6 +252,7 @@ var shimExecCommand = cli.Command{
}
rq := &shim.ExecProcessRequest{
ID: id,
Spec: &protobuf.Any{
TypeUrl: url,
Value: spec,
@@ -269,7 +280,7 @@ var shimExecCommand = cli.Command{
return err
}
if _, err := service.ResizePty(ctx, &shim.ResizePtyRequest{
Pid: r.Pid,
ID: id,
Width: uint32(size.Width),
Height: uint32(size.Height),
}); err != nil {