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

fix usage loss for snapshots with labels in MergeSnapshotter #4389

Merged
merged 1 commit into from
Nov 3, 2023
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
6 changes: 6 additions & 0 deletions snapshot/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,25 @@ func mergeUsageOf(info snapshots.Info) (usage snapshots.Usage, ok bool, rerr err
if info.Labels == nil {
return snapshots.Usage{}, false, nil
}
hasMergeUsageLabel := false
if str, ok := info.Labels[mergeUsageSizeLabel]; ok {
i, err := strconv.Atoi(str)
if err != nil {
return snapshots.Usage{}, false, err
}
usage.Size = int64(i)
hasMergeUsageLabel = true
}
if str, ok := info.Labels[mergeUsageInodesLabel]; ok {
i, err := strconv.Atoi(str)
if err != nil {
return snapshots.Usage{}, false, err
}
usage.Inodes = int64(i)
hasMergeUsageLabel = true
}
if !hasMergeUsageLabel {
return snapshots.Usage{}, false, nil
}
return usage, true, nil
}