Avoid overflowing int64 in RoundUpSize and return error if overflow int

This commit is contained in:
Matthew Wong
2018-07-20 15:54:55 -04:00
parent d08e68e759
commit 093e231289
14 changed files with 94 additions and 36 deletions

View File

@@ -579,7 +579,10 @@ func (util *RBDUtil) CreateImage(p *rbdVolumeProvisioner) (r *v1.RBDPersistentVo
capacity := p.options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
volSizeBytes := capacity.Value()
// Convert to MB that rbd defaults on.
sz := int(volutil.RoundUpSize(volSizeBytes, 1024*1024))
sz, err := volutil.RoundUpSizeInt(volSizeBytes, 1024*1024)
if err != nil {
return nil, 0, err
}
volSz := fmt.Sprintf("%d", sz)
mon := util.kernelRBDMonitorsOpt(p.Mon)
if p.rbdMounter.imageFormat == rbdImageFormat2 {