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

br: volume-snapshot may lead to a panic when there is no block change between two snapshot #4922

Merged
merged 9 commits into from
Mar 7, 2023
6 changes: 2 additions & 4 deletions cmd/backup-manager/app/util/backup_size.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ func changedBlocksSize(preSnapshotId string, snapshotId string) (uint64, uint64,
}

var nextToken *string
var blockSize uint64

for {
resp, err := ebsSession.EBS.ListChangedBlocks(&ebs.ListChangedBlocksInput{
Expand All @@ -350,8 +349,7 @@ func changedBlocksSize(preSnapshotId string, snapshotId string) (uint64, uint64,
// retrieve only changed block and blocks only existed in current snapshot (new add blocks)
for _, block := range resp.ChangedBlocks {
if block.SecondBlockToken != nil && resp.BlockSize != nil {
blockSize = uint64(*resp.BlockSize)
snapshotSize += 1 * blockSize
snapshotSize += uint64(*resp.BlockSize)
}
}

Expand All @@ -361,6 +359,6 @@ func changedBlocksSize(preSnapshotId string, snapshotId string) (uint64, uint64,
}
nextToken = resp.NextToken
}
klog.Infof("the total size of snapshot %d, num of api ListChangedBlocks request %d, snapshot id %s, data change rate %.4f", snapshotSize, numApiReq, snapshotId, float64(snapshotSize/blockSize)/float64(numBlocks))
klog.Infof("the total size of snapshot %d, num of api ListChangedBlocks request %d, snapshot id %s", snapshotSize, numApiReq, snapshotId)
return snapshotSize, numApiReq, nil
}