Skip to content

Commit 3a38a2b

Browse files
authored
Merge pull request #11 from runloopai/adam/tar
Detect existing overlaybd layers during conversion
2 parents 3ad4637 + 214c850 commit 3a38a2b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

cmd/convertor/builder/overlaybd_builder.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
const (
4242
overlaybdBaseLayer = "/opt/overlaybd/baselayers/ext4_64"
4343
commitFile = "overlaybd.commit"
44+
layerTarFile = "layer.tar"
4445
labelDistributionSource = "containerd.io/distribution.source"
4546
)
4647

@@ -114,6 +115,18 @@ func (e *overlaybdBuilderEngine) BuildLayer(ctx context.Context, idx int) error
114115
} else {
115116
return fmt.Errorf("layer %d is from dedup but commit file is missing", idx)
116117
}
118+
} else if _, ok := e.manifest.Layers[idx].Annotations[label.OverlayBDBlobDigest]; ok {
119+
// this layer is already an overlaybd layer
120+
if commitFilePresent {
121+
return fmt.Errorf("layer %d was not converted yet a commit file is present", idx)
122+
}
123+
124+
logrus.Debugf("layer %d is already in overlaybd format", idx)
125+
126+
// Simply rename the layer.tar file to the commit file.
127+
if err := os.Rename(path.Join(layerDir, layerTarFile), path.Join(layerDir, commitFile)); err != nil {
128+
return errors.Wrapf(err, "failed to prepare overlaybd layer %d for mounting", idx)
129+
}
117130
} else {
118131
// This should not happen, but if it does, we should fail the conversion or
119132
// risk corrupting the image.

0 commit comments

Comments
 (0)