MCPcopy
hub / github.com/containerd/containerd / WithSnapshotCleanup

Function WithSnapshotCleanup

client/container_opts.go:224–238  ·  view source on GitHub ↗

WithSnapshotCleanup deletes the rootfs snapshot allocated for the container

(ctx context.Context, client *Client, c containers.Container)

Source from the content-addressed store, hash-verified

222
223// WithSnapshotCleanup deletes the rootfs snapshot allocated for the container
224func WithSnapshotCleanup(ctx context.Context, client *Client, c containers.Container) error {
225 if c.SnapshotKey != "" {
226 if c.Snapshotter == "" {
227 return fmt.Errorf("container.Snapshotter must be set to cleanup rootfs snapshot: %w", errdefs.ErrInvalidArgument)
228 }
229 s, err := client.getSnapshotter(ctx, c.Snapshotter)
230 if err != nil {
231 return err
232 }
233 if err := s.Remove(ctx, c.SnapshotKey); err != nil && !errdefs.IsNotFound(err) {
234 return err
235 }
236 }
237 return nil
238}
239
240// WithNewSnapshot allocates a new snapshot to be used by the container as the
241// root filesystem in read-write mode

Callers

nothing calls this directly

Calls 2

RemoveMethod · 0.65
getSnapshotterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…