Skip to content

storage: preserve original compressed layer blob alongside extracted content #1011

Description

@sohankunkerkar

Problem

Today, when a layer is pulled from a registry, applyDiff decompresses the layer into the overlay diff/ directory and discards the original compressed blob. Once that happens, the exact bytes corresponding to the registry digest are no longer available locally.

This isn't an issue for running containers, but it becomes a problem for workflows that need the original compressed blob again. As AI/ML images continue to grow, often into the tens of gigabytes, re-pulling just to get the original compressed form back becomes increasingly expensive.

Proposal

I'd like to add an optional PreserveCompressedBlob flag to LayerOptions.

When enabled, the original compressed layer would be saved alongside the existing layer metadata in the overlay storage. This would preserve the exact registry blob while still allowing the normal unpack flow to continue unchanged.

One detail worth noting: the preservation should be gated on whether the incoming stream is actually compressed (via archive.DetectCompression, which is already computed at the insertion point), rather than on whether OriginalDigest is set — there's a layer-reuse path where the digest is present but the stream is uncompressed.

The first consumer would be CRI-O, which could opt into this behavior during image pulls.

Why this approach?

The proposal is intentionally opt-in, so existing behavior remains unchanged unless a caller explicitly requests blob preservation.

It also fits naturally into the current storage model. The blob has the same lifetime as the layer itself, so normal image garbage collection automatically removes it. No additional cleanup mechanism is needed.

Initially this would only be supported by the overlay driver. Other drivers could opt in later if there's interest.

If this direction makes sense, I'm happy to put together a PR with the implementation details and discuss the API there.

cc @mtrmac @Luap99 @giuseppe @haircommander

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions