From 214c85054cfd23b833d832dd149ae9da8f0ea834 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Thu, 7 Aug 2025 15:36:20 -0700 Subject: [PATCH] Detect existing overlaybd layers during conversion These layer.tar files should be used directly and not applied as a file. --- cmd/convertor/builder/overlaybd_builder.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/convertor/builder/overlaybd_builder.go b/cmd/convertor/builder/overlaybd_builder.go index 99d624d8..99d52623 100644 --- a/cmd/convertor/builder/overlaybd_builder.go +++ b/cmd/convertor/builder/overlaybd_builder.go @@ -41,6 +41,7 @@ import ( const ( overlaybdBaseLayer = "/opt/overlaybd/baselayers/ext4_64" commitFile = "overlaybd.commit" + layerTarFile = "layer.tar" labelDistributionSource = "containerd.io/distribution.source" ) @@ -114,6 +115,18 @@ func (e *overlaybdBuilderEngine) BuildLayer(ctx context.Context, idx int) error } else { return fmt.Errorf("layer %d is from dedup but commit file is missing", idx) } + } else if _, ok := e.manifest.Layers[idx].Annotations[label.OverlayBDBlobDigest]; ok { + // this layer is already an overlaybd layer + if commitFilePresent { + return fmt.Errorf("layer %d was not converted yet a commit file is present", idx) + } + + logrus.Debugf("layer %d is already in overlaybd format", idx) + + // Simply rename the layer.tar file to the commit file. + if err := os.Rename(path.Join(layerDir, layerTarFile), path.Join(layerDir, commitFile)); err != nil { + return errors.Wrapf(err, "failed to prepare overlaybd layer %d for mounting", idx) + } } else { // This should not happen, but if it does, we should fail the conversion or // risk corrupting the image.