Skip to content

Commit 8244761

Browse files
committed
fix trace blob detected as leaked blob in tests
Trace blob is created 3 seconds after build completion. If this happens after test has cleaned all history records and before it checks for leaked blobs, test can report the trace blob as leaked. In practice it would be cleaned up next time containerd GC gets triggered. Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 474135f commit 8244761

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

control/control.go

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ func (c *Controller) ListenBuildHistory(req *controlapi.BuildHistoryRequest, srv
311311

312312
func (c *Controller) UpdateBuildHistory(ctx context.Context, req *controlapi.UpdateBuildHistoryRequest) (*controlapi.UpdateBuildHistoryResponse, error) {
313313
if req.Delete {
314+
c.history.Finalize(ctx, req.Ref) // ignore error
314315
err := c.history.Delete(ctx, req.Ref)
315316
return &controlapi.UpdateBuildHistoryResponse{}, err
316317
}

snapshot/containerd/content.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,20 @@ func (c *nsFallbackStore) Update(ctx context.Context, info content.Info, fieldpa
115115
}
116116

117117
func (c *nsFallbackStore) Walk(ctx context.Context, fn content.WalkFunc, filters ...string) error {
118-
return c.main.Walk(ctx, fn, filters...)
118+
seen := make(map[digest.Digest]struct{})
119+
err := c.main.Walk(ctx, func(i content.Info) error {
120+
seen[i.Digest] = struct{}{}
121+
return fn(i)
122+
}, filters...)
123+
if err != nil {
124+
return err
125+
}
126+
return c.fb.Walk(ctx, func(i content.Info) error {
127+
if _, ok := seen[i.Digest]; ok {
128+
return nil
129+
}
130+
return fn(i)
131+
}, filters...)
119132
}
120133

121134
func (c *nsFallbackStore) Delete(ctx context.Context, dgst digest.Digest) error {

0 commit comments

Comments
 (0)