Skip to content

Commit

Permalink
fix lsblk float issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Glonek committed Dec 20, 2023
1 parent de92ec7 commit 6249014
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 7.2.2
* Fix: `lsblk` now shows sizes as float not int.

#### 7.2.1
* Fix: New exporter name changes cause 1.15.0 to not install. This uses the new names.

Expand Down
23 changes: 21 additions & 2 deletions src/cmdClusterPartitionConf.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"log"
"math"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -285,7 +286,16 @@ func (c *clusterPartitionConfCmd) do(nodeNo int, disks map[int]map[int]blockDevi
pp := p.MountPoint
vals = append(vals, &pp)
cc.Stanza("namespace "+c.Namespace).Stanza("index-type flash").SetValues("mount", vals)
fsSizeI, err := strconv.Atoi(strings.TrimRight(p.FsSize, "GMBTgmbti"))
var fsSizeI int
if strings.Contains(p.FsSize, ".") {
var fsSizeF float64
fsSizeF, err = strconv.ParseFloat(strings.TrimRight(p.FsSize, "GMBTgmbti"), 64)
if err == nil {
fsSizeI = int(math.Floor(fsSizeF))
}
} else {
fsSizeI, err = strconv.Atoi(strings.TrimRight(p.FsSize, "GMBTgmbti"))
}
fsSize := p.FsSize
if err == nil {
suffix := ""
Expand All @@ -312,7 +322,16 @@ func (c *clusterPartitionConfCmd) do(nodeNo int, disks map[int]map[int]blockDevi
pp := p.MountPoint
vals = append(vals, &pp)
cc.Stanza("namespace "+c.Namespace).Stanza("sindex-type flash").SetValues("mount", vals)
fsSizeI, err := strconv.Atoi(strings.TrimRight(p.FsSize, "GMBTgmbti"))
var fsSizeI int
if strings.Contains(p.FsSize, ".") {
var fsSizeF float64
fsSizeF, err = strconv.ParseFloat(strings.TrimRight(p.FsSize, "GMBTgmbti"), 64)
if err == nil {
fsSizeI = int(math.Floor(fsSizeF))
}
} else {
fsSizeI, err = strconv.Atoi(strings.TrimRight(p.FsSize, "GMBTgmbti"))
}
fsSize := p.FsSize
if err == nil {
suffix := ""
Expand Down

0 comments on commit 6249014

Please sign in to comment.