MCPcopy
hub / github.com/containerd/containerd / Exec

Method Exec

client/task.go:443–489  ·  view source on GitHub ↗
(ctx context.Context, id string, spec *specs.Process, ioCreate cio.Creator)

Source from the content-addressed store, hash-verified

441}
442
443func (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
491func (t *task) Pids(ctx context.Context) ([]ProcessInfo, error) {
492 response, err := t.client.TaskService().ListPids(ctx, &tasks.ListPidsRequest{

Callers

nothing calls this directly

Calls 14

IDMethod · 0.95
StartSpanFunction · 0.92
NameFunction · 0.92
WithAttributeFunction · 0.92
WithNamespaceFunction · 0.92
AttributeFunction · 0.92
EndMethod · 0.80
SetAttributesMethod · 0.80
TaskServiceMethod · 0.80
CancelMethod · 0.65
CloseMethod · 0.65
ConfigMethod · 0.65

Tested by

no test coverage detected