Skip to content

Commit

Permalink
Move TurboOCI JSON construction to sn.Commit()
Browse files Browse the repository at this point in the history
We need to find the specific files in the unpacked tar layer for
TurboOCI multiple fs support, so move it to sn.Commit().

Signed-off-by: Gao Xiang <[email protected]>
  • Loading branch information
hsiangkao committed Jun 27, 2024
1 parent a4b1b4a commit daacefc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/snapshot/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,9 @@ func (o *snapshotter) createMountPoint(ctx context.Context, kind snapshots.Kind,
}, nil
}

// Normal prepare
// Normal prepare for TurboOCI
if isTurboOCI, digest, _ := o.checkTurboOCI(info.Labels); isTurboOCI {
log.G(ctx).Infof("%s is turboOCI.v1 layer: %s", s.ID, digest)
if err := o.constructOverlayBDSpec(ctx, key, false); err != nil {
return nil, err
}
stype = storageTypeNormal
}
if stype == storageTypeRemoteBlock {
Expand Down Expand Up @@ -823,6 +820,17 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
}

log.G(ctx).Debugf("Commit info (id: %s, info: %v, stype: %d)", id, info.Labels, stype)

// For turboOCI, we need to construct OverlayBD spec after unpacking
// since there could be multiple fs metadata in a turboOCI layer
if isTurboOCI, digest, _ := o.checkTurboOCI(info.Labels); isTurboOCI {
log.G(ctx).Infof("commit turboOCI.v1 layer: (%s, %s)", id, digest)
if err := o.constructOverlayBDSpec(ctx, name, false); err != nil {
return errors.Wrapf(err, "failed to construct overlaybd config")
}
stype = storageTypeNormal
}

// Firstly, try to convert an OCIv1 tarball to a turboOCI layer.
// then change stype to 'storageTypeLocalBlock' which can make it attach a overlaybd block
if stype == storageTypeLocalLayer {
Expand Down

0 comments on commit daacefc

Please sign in to comment.