Merge pull request #3409 from noahdesu/pvc-binding-size-suffix

ceph: adjust M-to-Mi rounding in PV creation
This commit is contained in:
Sébastien Han
2019-07-09 09:38:04 +02:00
committed by GitHub
2 changed files with 27 additions and 3 deletions
+13 -1
View File
@@ -25,6 +25,7 @@ import (
"regexp"
"github.com/rook/rook/pkg/clusterd"
"github.com/rook/rook/pkg/util/display"
"github.com/rook/rook/pkg/util/exec"
)
@@ -68,6 +69,9 @@ func ListImages(context *clusterd.Context, clusterName, poolName string) ([]Ceph
// CreateImage creates a block storage image.
// If dataPoolName is not empty, the image will use poolName as the metadata pool and the dataPoolname for data.
// If size is zero an empty image will be created. Otherwise, an image will be
// created with a size rounded up to the nearest Mi. The adjusted image size is
// placed in return value CephBlockImage.Size.
func CreateImage(context *clusterd.Context, clusterName, name, poolName, dataPoolName string, size uint64) (*CephBlockImage, error) {
if size > 0 && size < ImageMinSize {
// rbd tool uses MB as the smallest unit for size input. 0 is OK but anything else smaller
@@ -100,7 +104,15 @@ func CreateImage(context *clusterd.Context, clusterName, name, poolName, dataPoo
}
}
return &CephBlockImage{Name: name, Size: size}, nil
// report the adjusted size which will always be >= to the requested size
var newSizeBytes uint64
if sizeMB > 0 {
newSizeBytes = display.MbTob(uint64(sizeMB))
} else {
newSizeBytes = 0
}
return &CephBlockImage{Name: name, Size: newSizeBytes}, nil
}
func DeleteImage(context *clusterd.Context, clusterName, name, poolName string) error {