Skip to content

Commit

Permalink
Fix uploading for block devices that exceed requested size
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
  • Loading branch information
kvaps committed Oct 14, 2024
1 parent 7b330eb commit 90fdd7f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/importer/data-processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,14 @@ func (dp *DataProcessor) calculateTargetSize() int64 {
klog.V(1).Infof("Request image size not empty.\n")
newImageSizeQuantity := resource.MustParse(dp.requestImageSize)
minQuantity := util.MinQuantity(targetQuantity, &newImageSizeQuantity)
targetQuantity = &minQuantity
// Override target size to the requested one
if size >= int64(0) {
// Filesystem volume
targetQuantity = &minQuantity
} else if targetQuantity.Cmp(minQuantity) == -1 {
// Block volume with size smaller than requested
targetQuantity = &minQuantity
}
}
klog.V(1).Infof("Target size %s.\n", targetQuantity.String())
targetSize := targetQuantity.Value()
Expand Down

0 comments on commit 90fdd7f

Please sign in to comment.