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

Method Delete

client/container.go:186–204  ·  view source on GitHub ↗

Delete deletes an existing container an error is returned if the container has running tasks

(ctx context.Context, opts ...DeleteOpts)

Source from the content-addressed store, hash-verified

184// Delete deletes an existing container
185// an error is returned if the container has running tasks
186func (c *container) Delete(ctx context.Context, opts ...DeleteOpts) error {
187 ctx, span := tracing.StartSpan(ctx, "container.Delete",
188 tracing.WithAttribute("container.id", c.id),
189 )
190 defer span.End()
191 if _, err := c.loadTask(ctx, nil); err == nil {
192 return fmt.Errorf("cannot delete running task %v: %w", c.id, errdefs.ErrFailedPrecondition)
193 }
194 r, err := c.get(ctx)
195 if err != nil {
196 return err
197 }
198 for _, o := range opts {
199 if err := o(ctx, c.client, r); err != nil {
200 return err
201 }
202 }
203 return c.client.ContainerService().Delete(ctx, c.id)
204}
205
206func (c *container) Task(ctx context.Context, attach cio.Attach) (Task, error) {
207 return c.loadTask(ctx, attach)

Callers

nothing calls this directly

Calls 7

loadTaskMethod · 0.95
getMethod · 0.95
StartSpanFunction · 0.92
WithAttributeFunction · 0.92
EndMethod · 0.80
ContainerServiceMethod · 0.80
DeleteMethod · 0.65

Tested by

no test coverage detected