Skip to content

Conversation

ChengyuZhu6
Copy link
Member

This commit modifies getCleanupDirectories() to:

  • Only clean up remote snapshots (those with remoteLabel) during Close()
  • Preserve normal snapshot directories and their content
  • Ensure normal snapshots remain functional after restart

Fixes: #2126

if err := storage.WalkInfo(ctx, func(ctx context.Context, info snapshots.Info) error {
if _, ok := info.Labels[remoteLabel]; !ok {
if id, exists := keyToID[info.Name]; exists {
delete(ids, id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of giving two different meanings to ids depending on cleanupCommited value, can you just add a remoteSnapshotNames := make(map[string]struct{}) which caches all remote snapshot names and do something like the following in the loop at L459?

for _, d := range dirs {
	if !cleanupCommitted {
		if _, ok := ids[d]; ok {
			continue
		}
	} else {
		if _, ok := remoteSnapshotNames[d]; !ok {
			continue // do not delete local snapshots
		}
	}

	cleanup = append(cleanup, filepath.Join(snapshotDir, d))
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I'll make the change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ChengyuZhu6 ChengyuZhu6 force-pushed the cleanup branch 2 times, most recently from 0c8c930 to 648a91a Compare September 18, 2025 11:01
@ChengyuZhu6 ChengyuZhu6 requested a review from ktock September 18, 2025 11:14
@ktock
Copy link
Member

ktock commented Sep 30, 2025

@ChengyuZhu6 Could you rebase the patch to pass CI?

@ChengyuZhu6
Copy link
Member Author

@ChengyuZhu6 Could you rebase the patch to pass CI?

Sure.

This commit modifies getCleanupDirectories() to:
- Only clean up remote snapshots (those with remoteLabel) during Close()
- Preserve normal snapshot directories and their content
- Ensure normal snapshots remain functional after restart

Signed-off-by: ChengyuZhu6 <[email protected]>
Copy link
Member

@ktock ktock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@ktock ktock merged commit c0055f8 into containerd:main Sep 30, 2025
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Normal snapshots lost after stargz snapshotter restart, causing container startup failures

2 participants