Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Modify the logic of obtaining image ref when deleting snapshots #170

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,18 @@ func (o *snapshotter) Remove(ctx context.Context, key string) error {
return errors.Wrap(err, "failed to get snapshot")
}

// workaround for cacheMgr
// It is not necessary to execute successfully, even if it fails, it does not affect removing snapshot
if snap.Labels != nil {
if imageID, ok := snap.Labels[label.CRIImageRef]; ok {
if err := o.fs.DelSnapshot(imageID); err != nil {
return errors.Wrap(err, "failed to delete snapshot in cache manager")
if _, ok := snap.Labels[label.TargetSnapshotRef]; ok {
if imageID, ok := snap.Labels[label.CRIImageRef]; ok {
Copy link
Member

Choose a reason for hiding this comment

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

Why need to check if a particular label existed for the deleted snapshot? What's the problem if we delete a snapshot which does not meet the labels combination?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it work for OCI image layer?

Copy link
Member

Choose a reason for hiding this comment

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

As discussed with @power-more , it does not affect the OCI layer.

if err := o.fs.DelSnapshot(imageID); err != nil {
log.G(ctx).WithError(err).Warn("failed to delete snapshot in cache manager")
}
} else {
log.G(ctx).WithError(err).Warnf("failed to get image ref from snapshot label %#v", snap.Labels)

}
} else {
return fmt.Errorf("failed to get image ref from snapshot label %#v", snap.Labels)
}
}

Expand Down