Skip to content

Commit

Permalink
snapshot: use temporary lease during diffapply.
Browse files Browse the repository at this point in the history
A temporary lease ctx was previously made during the snapshotter Merge
method but it was not passed to diffApply, which may have meant that
temporary View snapshots created there could be garbage collected by
containerd at any time.

It's possible this was encountered in CI, but I was unable to reproduce
the failure after 1000 attempts locally, so this commit is just a best
guess at the problem.

Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 868f78d)
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
sipsma authored and tonistiigi committed Apr 6, 2022
1 parent 75ba987 commit ea3a19b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions snapshot/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ func (sn *mergeSnapshotter) Merge(ctx context.Context, key string, diffs []Diff,
diffs = diffs[baseIndex:]
}

tempLeaseCtx, done, err := leaseutil.WithLease(ctx, sn.lm, leaseutil.MakeTemporary)
ctx, done, err := leaseutil.WithLease(ctx, sn.lm, leaseutil.MakeTemporary)
if err != nil {
return errors.Wrap(err, "failed to create temporary lease for view mounts during merge")
}
defer done(context.TODO())

// Make the snapshot that will be merged into
prepareKey := identity.NewID()
if err := sn.Prepare(tempLeaseCtx, prepareKey, baseKey); err != nil {
if err := sn.Prepare(ctx, prepareKey, baseKey); err != nil {
return errors.Wrapf(err, "failed to prepare %q", key)
}
applyMounts, err := sn.Mounts(ctx, prepareKey)
Expand Down

0 comments on commit ea3a19b

Please sign in to comment.