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 <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2025-02-25 09:26:59 -08:00
parent 474135feea
commit 8244761d21
2 changed files with 15 additions and 1 deletions

View File

@@ -311,6 +311,7 @@ func (c *Controller) ListenBuildHistory(req *controlapi.BuildHistoryRequest, srv
func (c *Controller) UpdateBuildHistory(ctx context.Context, req *controlapi.UpdateBuildHistoryRequest) (*controlapi.UpdateBuildHistoryResponse, error) {
if req.Delete {
c.history.Finalize(ctx, req.Ref) // ignore error
err := c.history.Delete(ctx, req.Ref)
return &controlapi.UpdateBuildHistoryResponse{}, err
}

View File

@@ -115,7 +115,20 @@ func (c *nsFallbackStore) Update(ctx context.Context, info content.Info, fieldpa
}
func (c *nsFallbackStore) Walk(ctx context.Context, fn content.WalkFunc, filters ...string) error {
return c.main.Walk(ctx, fn, filters...)
seen := make(map[digest.Digest]struct{})
err := c.main.Walk(ctx, func(i content.Info) error {
seen[i.Digest] = struct{}{}
return fn(i)
}, filters...)
if err != nil {
return err
}
return c.fb.Walk(ctx, func(i content.Info) error {
if _, ok := seen[i.Digest]; ok {
return nil
}
return fn(i)
}, filters...)
}
func (c *nsFallbackStore) Delete(ctx context.Context, dgst digest.Digest) error {