(ctx context.Context, id string, spec *specs.Process, ioCreate cio.Creator)
| 441 | } |
| 442 | |
| 443 | func (t *task) Exec(ctx context.Context, id string, spec *specs.Process, ioCreate cio.Creator) (_ Process, retErr error) { |
| 444 | ctx, span := tracing.StartSpan(ctx, tracing.Name("client.task", "Exec"), |
| 445 | tracing.WithAttribute("task.id", t.ID()), |
| 446 | tracing.WithNamespace(ctx), |
| 447 | ) |
| 448 | defer span.End() |
| 449 | |
| 450 | if id == "" { |
| 451 | return nil, fmt.Errorf("exec id must not be empty: %w", errdefs.ErrInvalidArgument) |
| 452 | } |
| 453 | span.SetAttributes(tracing.Attribute("task.exec.id", id)) |
| 454 | i, err := ioCreate(id) |
| 455 | if err != nil { |
| 456 | return nil, err |
| 457 | } |
| 458 | defer func() { |
| 459 | if retErr != nil && i != nil { |
| 460 | i.Cancel() |
| 461 | i.Close() |
| 462 | } |
| 463 | }() |
| 464 | pSpec, err := typeurl.MarshalAnyToProto(spec) |
| 465 | if err != nil { |
| 466 | return nil, err |
| 467 | } |
| 468 | cfg := i.Config() |
| 469 | request := &tasks.ExecProcessRequest{ |
| 470 | ContainerID: t.id, |
| 471 | ExecID: id, |
| 472 | Terminal: cfg.Terminal, |
| 473 | Stdin: cfg.Stdin, |
| 474 | Stdout: cfg.Stdout, |
| 475 | Stderr: cfg.Stderr, |
| 476 | Spec: pSpec, |
| 477 | } |
| 478 | if _, err := t.client.TaskService().Exec(ctx, request); err != nil { |
| 479 | i.Cancel() |
| 480 | i.Wait() |
| 481 | i.Close() |
| 482 | return nil, errgrpc.ToNative(err) |
| 483 | } |
| 484 | return &process{ |
| 485 | id: id, |
| 486 | task: t, |
| 487 | io: i, |
| 488 | }, nil |
| 489 | } |
| 490 | |
| 491 | func (t *task) Pids(ctx context.Context) ([]ProcessInfo, error) { |
| 492 | response, err := t.client.TaskService().ListPids(ctx, &tasks.ListPidsRequest{ |
nothing calls this directly
no test coverage detected