MCPcopy
hub / github.com/containerd/containerd / Delete

Method Delete

client/process.go:232–263  ·  view source on GitHub ↗
(ctx context.Context, opts ...ProcessDeleteOpts)

Source from the content-addressed store, hash-verified

230}
231
232func (p *process) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStatus, error) {
233 ctx, span := tracing.StartSpan(ctx, "process.Delete",
234 tracing.WithAttribute("process.id", p.ID()),
235 )
236 defer span.End()
237 for _, o := range opts {
238 if err := o(ctx, p); err != nil {
239 return nil, err
240 }
241 }
242 status, err := p.Status(ctx)
243 if err != nil {
244 return nil, err
245 }
246 switch status.Status {
247 case Running, Paused, Pausing:
248 return nil, fmt.Errorf("current process state: %s, process must be stopped before deletion: %w", status.Status, errdefs.ErrFailedPrecondition)
249 }
250 r, err := p.task.client.TaskService().DeleteProcess(ctx, &tasks.DeleteProcessRequest{
251 ContainerID: p.task.id,
252 ExecID: p.id,
253 })
254 if err != nil {
255 return nil, errgrpc.ToNative(err)
256 }
257 if p.io != nil {
258 p.io.Cancel()
259 p.io.Wait()
260 p.io.Close()
261 }
262 return &ExitStatus{code: r.ExitStatus, exitedAt: protobuf.FromTimestamp(r.ExitedAt)}, nil
263}
264
265func (p *process) Status(ctx context.Context) (Status, error) {
266 r, err := p.task.client.TaskService().Get(ctx, &tasks.GetRequest{

Callers

nothing calls this directly

Calls 11

IDMethod · 0.95
StatusMethod · 0.95
StartSpanFunction · 0.92
WithAttributeFunction · 0.92
FromTimestampFunction · 0.92
EndMethod · 0.80
TaskServiceMethod · 0.80
DeleteProcessMethod · 0.65
CancelMethod · 0.65
WaitMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected