overlay

package
v0.9.302 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package overlay provides shared helpers for restoring a container's overlayfs RW (upper) layer from a dump.

It lives in the parent module so that runc plugin, the containerd plugin, and the containerd runtime shim (cedana-containerd-runtime) can all use it.

The Linux overlayfs contract states that modifying the underlying upper/lower directories of a *mounted* overlay is undefined behavior. Therefore the RW layer must be restored into the upperdir *before* the overlay is mounted, and only the component that performs the mount can do that: the containerd shim (cedana-containerd-runtime), which populates the upperdir just before mount.All on every restore path (Kubernetes and CLI alike). It drops a marker so the runc plugin's post-mount restore is a no-op.

The runc plugin's post-mount restore remains as a fallback for the cases the shim cannot handle (no readable checkpoint directory, e.g. streamed dumps whose RW layer lives inside stream shards, or plain runc restores where the overlay was mounted by a third party).

Index

Constants

View Source
const (
	DumpRWLayerManifestKey    = "rw-layer.manifest"
	DumpRWLayerBatchFormatter = "rw-layer-%d.img"
)

RW-layer dump file names. This is the single source of truth: the dump side (plugins/runc) and every restore site (runc plugin, containerd plugin, and the containerd runtime shim) reference these constants.

View Source
const RestoredMarker = ".cedana-rw-restored"

RestoredMarker is dropped in the snapshot directory (the parent of the upperdir, which is outside the overlay's merged view and therefore invisible to the container) once the RW layer has been restored. Its presence tells a later, redundant restore attempt to skip and avoid a double-populate.

Variables

This section is empty.

Functions

func AlreadyRestored

func AlreadyRestored(upperDir string) bool

func MarkerPath

func MarkerPath(upperDir string) string

func RestoreToUpperDir

func RestoreToUpperDir(ctx context.Context, dump afero.Fs, upperDir string) (restored bool, err error)

RestoreToUpperDir reads the RW-layer batches from the dump filesystem and writes them into upperDir. Returns restored=false (and no error) if the dump has no readable RW-layer manifest — e.g. the checkpoint has no RW layer at all, or it is a streamed dump whose RW layer lives inside stream shards. Callers must only drop the restored marker when restored is true, otherwise the post-mount fallback (which may have a streaming-capable dump filesystem) would be skipped and the RW layer silently lost.

func UpperDirFromMountOptions

func UpperDirFromMountOptions(options []string) (string, error)

UpperDirFromMountOptions extracts the upperdir from a set of overlay mount options

func WriteMarker

func WriteMarker(upperDir string) error

WriteMarker records that the RW layer for the given upperdir has been restored.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL