MCPcopy Index your code
hub / github.com/containerd/containerd / Delete

Method Delete

core/metadata/containers.go:287–321  ·  view source on GitHub ↗
(ctx context.Context, id string)

Source from the content-addressed store, hash-verified

285}
286
287func (s *containerStore) Delete(ctx context.Context, id string) error {
288 ctx, span := tracing.StartSpan(ctx,
289 tracing.Name(spanContainerPrefix, "Delete"),
290 tracing.WithAttribute("container.id", id),
291 tracing.WithNamespace(ctx),
292 )
293 defer span.End()
294
295 if meta, err := s.Get(ctx, id); err == nil && meta.SandboxID != "" {
296 span.SetAttributes(tracing.Attribute("sandbox.id", meta.SandboxID))
297 }
298
299 namespace, err := namespaces.NamespaceRequired(ctx)
300 if err != nil {
301 return err
302 }
303
304 return update(ctx, s.db, func(tx *bolt.Tx) error {
305 bkt := getContainersBucket(tx, namespace)
306 if bkt == nil {
307 return fmt.Errorf("cannot delete container %q in namespace %q: %w", id, namespace, errdefs.ErrNotFound)
308 }
309
310 if err := bkt.DeleteBucket([]byte(id)); err != nil {
311 if err == errbolt.ErrBucketNotFound {
312 err = fmt.Errorf("container %v: %w", id, errdefs.ErrNotFound)
313 }
314 return err
315 }
316
317 s.db.dirty.Add(1)
318
319 return nil
320 })
321}
322
323func validateContainer(container *containers.Container) error {
324 if err := identifiers.Validate(container.ID); err != nil {

Callers

nothing calls this directly

Calls 12

GetMethod · 0.95
StartSpanFunction · 0.92
NameFunction · 0.92
WithAttributeFunction · 0.92
WithNamespaceFunction · 0.92
AttributeFunction · 0.92
NamespaceRequiredFunction · 0.92
updateFunction · 0.85
getContainersBucketFunction · 0.85
EndMethod · 0.80
SetAttributesMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected