Skip to content

Commit

Permalink
fix bug that gen layer tar contains duplicated files
Browse files Browse the repository at this point in the history
Signed-off-by: frankyang <[email protected]>
  • Loading branch information
yyb196 committed Nov 22, 2023
1 parent d5817ce commit 84c80f4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cache/blobs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,17 @@ func (sr *immutableRef) tryComputeOverlayBlob(ctx context.Context, lower, upper
if err != nil {
return emptyDesc, false, errors.Wrap(err, "failed to open writer")
}
cw.Truncate(0)
defer func() {
if cw != nil {
// after commit success cw will be set to nil, if cw isn't nil, error
// happened before commit, we should abort this ingest, and because the
// error may incured by ctx cancel, use a new context here. And since
// cm.Close will unlock this ref in the content store, we invoke abort
// to remove the ingest root in advance.
if aerr := sr.cm.ContentStore.Abort(context.Background(), ref); aerr != nil {
bklog.G(ctx).WithError(aerr).Warnf("failed to abort writer %q", ref)
}
if cerr := cw.Close(); cerr != nil {
bklog.G(ctx).WithError(cerr).Warnf("failed to close writer %q", ref)
}
Expand Down

0 comments on commit 84c80f4

Please sign in to comment.