Implement Exec + Start for tasks service

This splits up the exec creation and start in the tasks service

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-07-31 14:02:52 -04:00
parent 63878d14ea
commit a2a3451925
9 changed files with 350 additions and 194 deletions

21
task.go
View File

@@ -118,7 +118,7 @@ func (t *task) Start(ctx context.Context) error {
t.pid = response.Pid
return nil
}
_, err := t.client.TaskService().Start(ctx, &tasks.StartTaskRequest{
_, err := t.client.TaskService().Start(ctx, &tasks.StartRequest{
ContainerID: t.id,
})
if err != nil {
@@ -214,6 +214,25 @@ func (t *task) Exec(ctx context.Context, id string, spec *specs.Process, ioCreat
if err != nil {
return nil, err
}
any, err := typeurl.MarshalAny(spec)
if err != nil {
return nil, err
}
request := &tasks.ExecProcessRequest{
ContainerID: t.id,
ExecID: id,
Terminal: i.Terminal,
Stdin: i.Stdin,
Stdout: i.Stdout,
Stderr: i.Stderr,
Spec: any,
}
if _, err := t.client.TaskService().Exec(ctx, request); err != nil {
i.Cancel()
i.Wait()
i.Close()
return nil, err
}
return &process{
id: id,
task: t,