From 8c288ab62520abb1ef9b3ad2ca3cfd63fea30e27 Mon Sep 17 00:00:00 2001 From: Robert Glonek Date: Tue, 19 Dec 2023 17:41:24 -0800 Subject: [PATCH] fix lsblk float-int issue --- CHANGELOG.md | 4 ++++ src/cmdClusterPartitionConf.go | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59d9fb85..c9ccb0f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,8 +31,12 @@ * Fix: Auto-create temporary directory as needed, if it is specified. * Fix: GCP: Handle firewall rules which use an IP instead of CIDR. * Fix: New exporter name changes cause 1.15.0 to not install. This uses the new names. +* Fix: `lsblk` now shows sizes as float not int. * Aerospike Client Versions: `data insert`, `data delete` support for `v7` aerospike client. +#### 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. diff --git a/src/cmdClusterPartitionConf.go b/src/cmdClusterPartitionConf.go index 655ee1bc..265f3019 100644 --- a/src/cmdClusterPartitionConf.go +++ b/src/cmdClusterPartitionConf.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "log" + "math" "sort" "strconv" "strings" @@ -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 := "" @@ -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 := ""