From e7b3a67b41d85eab28564cf2ad3f1c56ec2ef5a6 Mon Sep 17 00:00:00 2001 From: Gautam Raj <156491596+gautam-rl@users.noreply.github.com> Date: Wed, 27 Aug 2025 21:07:49 -0700 Subject: [PATCH] Check the parent snapshot to identify the writable type --- pkg/snapshot/overlay.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pkg/snapshot/overlay.go b/pkg/snapshot/overlay.go index 7670020d..c4b61f80 100644 --- a/pkg/snapshot/overlay.go +++ b/pkg/snapshot/overlay.go @@ -413,8 +413,26 @@ func (o *snapshotter) getWritableType(ctx context.Context, id string, info snaps log.G(ctx).Debugf("OverlayBD labels detected for snapshot %s - using overlaybd (rwMode: %s)", id, o.rwMode) return rwMode(o.rwMode) } + // Fallback to checking the filesystem if labels are not present - stype, err := o.identifySnapshotStorageType(ctx, id, info) + // For write capability decisions, check the parent's storage type directly + var stype storageType + var err error + if id != "" && info.Parent != "" && o.isPrepareRootfs(info) { + // Get parent info and check its storage type + if _, parentInfo, _, err := storage.GetInfo(ctx, info.Parent); err == nil { + log.G(ctx).Debugf("getWritableType: checking parent snapshot %s for overlaybd format (child: %s)", id, info.Name) + stype, err = o.identifySnapshotStorageType(ctx, id, parentInfo) + } else { + // Fallback in case of error - probably should not happen. + log.G(ctx).Warnf("getWritableType: failed to get parent info for %s, checking child info: %v", info.Parent, err) + stype, err = o.identifySnapshotStorageType(ctx, id, info) + } + } else { + // Standard case: check the snapshot's own storage type + stype, err = o.identifySnapshotStorageType(ctx, id, info) + } + if err == nil && (stype == storageTypeLocalBlock || stype == storageTypeRemoteBlock) { log.G(ctx).Debugf("OverlayBD filesystem detected for snapshot %s - using overlaybd (rwMode: %s)", id, o.rwMode) return rwMode(o.rwMode)