Skip to content

Commit 21a2ad8

Browse files
authored
Check the parent snapshot to identify the writable type (#17)
**What this PR does / why we need it**: **What** Changes getWritableType() to look at the *parent* snapshot's filesystem instead of the child's, which doesn't even exist at this point. **Why** When creating sandboxes/containers from overlaybd pause images, the first creation works correctly but subsequent attempts fall back to overlayfs mode instead of using overlaybd. The getWritableType() function was checking the child snapshot's labels and filesystem for overlaybd metadata, but the child snapshot doesn't have a label, and the child snapshot directories don't exist yet at this point. **Please check the following list**: - [ ] Does the affected code have corresponding tests, e.g. unit test, E2E test? - [ ] Does this change require a documentation update? - [ ] Does this introduce breaking changes that would require an announcement or bumping the major version? - [ ] Do all new files have an appropriate license header? <!-- If this is a security issue, please do not discuss on GitHub. Please report any suspected or confirmed security issues directly to https://github.com/containerd/accelerated-container-image/blob/main/MAINTAINERS. -->
1 parent 6dd3055 commit 21a2ad8

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

pkg/snapshot/overlay.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,26 @@ func (o *snapshotter) getWritableType(ctx context.Context, id string, info snaps
413413
log.G(ctx).Debugf("OverlayBD labels detected for snapshot %s - using overlaybd (rwMode: %s)", id, o.rwMode)
414414
return rwMode(o.rwMode)
415415
}
416+
416417
// Fallback to checking the filesystem if labels are not present
417-
stype, err := o.identifySnapshotStorageType(ctx, id, info)
418+
// For write capability decisions, check the parent's storage type directly
419+
var stype storageType
420+
var err error
421+
if id != "" && info.Parent != "" && o.isPrepareRootfs(info) {
422+
// Get parent info and check its storage type
423+
if _, parentInfo, _, err := storage.GetInfo(ctx, info.Parent); err == nil {
424+
log.G(ctx).Debugf("getWritableType: checking parent snapshot %s for overlaybd format (child: %s)", id, info.Name)
425+
stype, err = o.identifySnapshotStorageType(ctx, id, parentInfo)
426+
} else {
427+
// Fallback in case of error - probably should not happen.
428+
log.G(ctx).Warnf("getWritableType: failed to get parent info for %s, checking child info: %v", info.Parent, err)
429+
stype, err = o.identifySnapshotStorageType(ctx, id, info)
430+
}
431+
} else {
432+
// Standard case: check the snapshot's own storage type
433+
stype, err = o.identifySnapshotStorageType(ctx, id, info)
434+
}
435+
418436
if err == nil && (stype == storageTypeLocalBlock || stype == storageTypeRemoteBlock) {
419437
log.G(ctx).Debugf("OverlayBD filesystem detected for snapshot %s - using overlaybd (rwMode: %s)", id, o.rwMode)
420438
return rwMode(o.rwMode)

0 commit comments

Comments
 (0)