MCPcopy
hub / github.com/containerd/containerd / startGCContext

Function startGCContext

core/metadata/gc.go:200–414  ·  view source on GitHub ↗
(ctx context.Context, collectors map[gc.ResourceType]Collector)

Source from the content-addressed store, hash-verified

198}
199
200func startGCContext(ctx context.Context, collectors map[gc.ResourceType]Collector) *gcContext {
201 var contexts map[gc.ResourceType]CollectionContext
202 labelHandlers := []referenceLabelHandler{
203 {
204 key: labelGCContainerBackRef,
205 bref: func(ns string, k, v []byte, fn func(gc.Node)) {
206 if ks := string(k); ks != string(labelGCContainerBackRef) {
207 // Allow reference naming separated by . or /, ignore names
208 if ks[len(labelGCContainerBackRef)] != '.' && ks[len(labelGCContainerBackRef)] != '/' {
209 return
210 }
211 }
212
213 fn(gcnode(ResourceContainer, ns, string(v)))
214 },
215 },
216 {
217 key: labelGCContentBackRef,
218 bref: func(ns string, k, v []byte, fn func(gc.Node)) {
219 if ks := string(k); ks != string(labelGCContentBackRef) {
220 // Allow reference naming separated by . or /, ignore names
221 if ks[len(labelGCContentBackRef)] != '.' && ks[len(labelGCContentBackRef)] != '/' {
222 return
223 }
224 }
225
226 fn(gcnode(ResourceContent, ns, string(v)))
227 },
228 },
229 {
230 key: labelGCImageBackRef,
231 bref: func(ns string, k, v []byte, fn func(gc.Node)) {
232 if ks := string(k); ks != string(labelGCImageBackRef) {
233 // Allow reference naming separated by . or /, ignore names
234 if ks[len(labelGCImageBackRef)] != '.' && ks[len(labelGCImageBackRef)] != '/' {
235 return
236 }
237 }
238
239 fn(gcnode(ResourceImage, ns, string(v)))
240 },
241 },
242 {
243 key: labelGCSnapBackRef,
244 bref: func(ns string, k, v []byte, fn func(gc.Node)) {
245 snapshotter := k[len(labelGCSnapBackRef):]
246 if i := bytes.IndexByte(snapshotter, '/'); i >= 0 {
247 snapshotter = snapshotter[:i]
248 }
249 fn(gcnode(ResourceSnapshot, ns, fmt.Sprintf("%s/%s", snapshotter, v)))
250 },
251 },
252 {
253 key: labelGCContentRef,
254 fn: func(ns string, k, v []byte, fn func(gc.Node)) {
255 if ks := string(k); ks != string(labelGCContentRef) {
256 // Allow reference naming separated by . or /, ignore names
257 if ks[len(labelGCContentRef)] != '.' && ks[len(labelGCContentRef)] != '/' {

Callers 6

TestGCRootsFunction · 0.85
TestGCRemoveFunction · 0.85
TestGCRefsFunction · 0.85
TestCollectibleResourcesFunction · 0.85
GarbageCollectMethod · 0.85
TestMetadataCollectorFunction · 0.85

Calls 4

gcnodeFunction · 0.70
StartCollectionMethod · 0.65
ReferenceLabelMethod · 0.65
CompareMethod · 0.65

Tested by 5

TestGCRootsFunction · 0.68
TestGCRemoveFunction · 0.68
TestGCRefsFunction · 0.68
TestCollectibleResourcesFunction · 0.68
TestMetadataCollectorFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…