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

Method Delete

core/runtime/v2/bundle.go:132–157  ·  view source on GitHub ↗

Delete a bundle atomically

()

Source from the content-addressed store, hash-verified

130
131// Delete a bundle atomically
132func (b *Bundle) Delete() error {
133 work, werr := os.Readlink(filepath.Join(b.Path, "work"))
134 rootfs := filepath.Join(b.Path, "rootfs")
135 if err := mount.UnmountRecursive(rootfs, 0); err != nil {
136 return fmt.Errorf("unmount rootfs %s: %w", rootfs, err)
137 }
138 if err := os.Remove(rootfs); err != nil && !os.IsNotExist(err) {
139 return fmt.Errorf("failed to remove bundle rootfs: %w", err)
140 }
141 err := atomicDelete(b.Path)
142 if err == nil {
143 if werr == nil {
144 return atomicDelete(work)
145 }
146 return nil
147 }
148 // error removing the bundle path; still attempt removing work dir
149 var err2 error
150 if werr == nil {
151 err2 = atomicDelete(work)
152 if err2 == nil {
153 return err
154 }
155 }
156 return fmt.Errorf("failed to remove both bundle and workdir locations: %v: %w", err2, err)
157}
158
159// atomicDelete renames the path to a hidden file before removal
160func atomicDelete(path string) error {

Callers 2

CreateMethod · 0.95
CreateMethod · 0.95

Calls 3

UnmountRecursiveFunction · 0.92
atomicDeleteFunction · 0.85
RemoveMethod · 0.65

Tested by

no test coverage detected