Skip to content

Commit 40d6580

Browse files
committed
CLI: extend 'show cluster' - add 'alert' column
* move version & build to the summary - show version (or build) with individual nodes _iff_ there are different versions and builds, respectively * add alert column; hide it _iff_ all state flags are OK - for enumeration, see cmn/cos/node_state_flags Signed-off-by: Alex Aizman <alex.aizman@gmail.com>
1 parent 5c94da9 commit 40d6580

File tree

8 files changed

+69
-9
lines changed

8 files changed

+69
-9
lines changed

ais/htrun.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,9 @@ func (h *htrun) statsAndStatus() (ds *stats.NodeStatus) {
11341134
Node: stats.Node{
11351135
Snode: h.si,
11361136
},
1137+
Cluster: cos.NodeStateInfo{
1138+
Flags: cos.NodeStateFlags(h.statsT.Get(stats.NodeStateFlags)),
1139+
},
11371140
SmapVersion: smap.Version,
11381141
MemCPUInfo: apc.GetMemCPU(),
11391142
DeploymentType: deploymentType(),

cmd/cli/cli/daeclu.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ func cluDaeStatus(c *cli.Context, smap *meta.Smap, tstatusMap, pstatusMap teb.St
6565
tableP := teb.NewDaeMapStatus(&body.Status, smap, apc.Proxy, units)
6666
tableT := teb.NewDaeMapStatus(&body.Status, smap, apc.Target, units)
6767

68-
// total num disks and capacity
68+
// totals: num disks and capacity; software version and build tiume
6969
body.NumDisks, body.Capacity = _totals(body.Status.Tmap, units, cfg)
70+
body.Version, body.BuildTime = _clusoft(body.Status.Tmap, body.Status.Pmap)
7071

7172
out := tableP.Template(false) + "\n"
7273
out += tableT.Template(false) + "\n"
@@ -133,3 +134,28 @@ outer:
133134

134135
return num, cs
135136
}
137+
138+
func _clusoft(nodemaps ...teb.StstMap) (version, build string) {
139+
var multiver, multibuild bool
140+
for _, m := range nodemaps {
141+
for _, ds := range m {
142+
if !multiver {
143+
if version == "" {
144+
version = ds.Version
145+
} else if version != ds.Version {
146+
multiver = true
147+
version = ""
148+
}
149+
}
150+
if !multibuild {
151+
if build == "" {
152+
build = ds.BuildTime
153+
} else if build != ds.BuildTime {
154+
multibuild = true
155+
build = ""
156+
}
157+
}
158+
}
159+
}
160+
return version, build
161+
}

cmd/cli/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/NVIDIA/aistore/cmd/cli
33
go 1.22.3
44

55
require (
6-
github.com/NVIDIA/aistore v1.3.24-0.20240819221047-053ce1175e42
6+
github.com/NVIDIA/aistore v1.3.24-0.20240821144511-7324344cd3cd
77
github.com/fatih/color v1.17.0
88
github.com/json-iterator/go v1.1.12
99
github.com/onsi/ginkgo/v2 v2.20.0

cmd/cli/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
code.cloudfoundry.org/bytefmt v0.0.0-20190710193110-1eb035ffe2b6/go.mod h1:wN/zk7mhREp/oviagqUXY3EwuHhWyOvAdsn5Y4CzOrc=
22
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
3-
github.com/NVIDIA/aistore v1.3.24-0.20240819221047-053ce1175e42 h1:JMzCMPLftDSGa6/TIXlHFCJCfLvPl+a20gf3ZY98OL4=
4-
github.com/NVIDIA/aistore v1.3.24-0.20240819221047-053ce1175e42/go.mod h1:si83S9r29vwIC0f0CE2Mk+25bFiaN6mmVlmuBpP4hHM=
3+
github.com/NVIDIA/aistore v1.3.24-0.20240821144511-7324344cd3cd h1:k619Yjgc8Rsei9yRiG4WwW+xrj8RstITaVtNPfuqB0c=
4+
github.com/NVIDIA/aistore v1.3.24-0.20240821144511-7324344cd3cd/go.mod h1:si83S9r29vwIC0f0CE2Mk+25bFiaN6mmVlmuBpP4hHM=
55
github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8=
66
github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
77
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=

cmd/cli/teb/daeclu.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ const (
2424
colLoadAvg = "LOAD AVERAGE"
2525
colRebalance = "REBALANCE"
2626
colUptime = "UPTIME"
27+
colPodName = "K8s POD"
2728
colStatus = "STATUS"
2829
colVersion = "VERSION"
2930
colBuildTime = "BUILD TIME"
30-
colPodName = "K8s POD"
31+
32+
colStateFlags = "ALERT"
3133
)
3234

3335
// TODO: extend api.GetClusterSysInfo() and api.GetStatsAndStatus to return memsys.Pressure
@@ -70,6 +72,7 @@ func newTableProxies(ps StstMap, smap *meta.Smap, units string) *Table {
7072
pods = h.pods()
7173
status = h.onlineStatus()
7274
versions = h.versions()
75+
builds = h.buildTimes()
7376
cols = []*header{
7477
{name: colProxy},
7578
{name: colMemUsed},
@@ -78,8 +81,9 @@ func newTableProxies(ps StstMap, smap *meta.Smap, units string) *Table {
7881
{name: colUptime},
7982
{name: colPodName, hide: len(pods) == 1 && pods[0] == ""},
8083
{name: colStatus, hide: len(status) == 1 && status[0] == NodeOnline},
81-
{name: colVersion, hide: len(versions) == 1 && len(ps) > 1},
82-
{name: colBuildTime, hide: len(versions) == 1 && len(ps) > 1}, // intended
84+
{name: colVersion, hide: len(versions) == 1 && len(builds) == 1},
85+
{name: colBuildTime, hide: len(versions) == 1 && len(builds) == 1},
86+
{name: colStateFlags, hide: ps.allStateFlagsOK()},
8387
}
8488
table = newTable(cols...)
8589
)
@@ -130,6 +134,7 @@ func newTableProxies(ps StstMap, smap *meta.Smap, units string) *Table {
130134
ds.Status,
131135
ds.Version,
132136
ds.BuildTime,
137+
ds.Cluster.Flags.String(),
133138
}
134139
table.addRow(row)
135140
}
@@ -170,6 +175,7 @@ func newTableTargets(ts StstMap, smap *meta.Smap, units string) *Table {
170175
pods = h.pods()
171176
status = h.onlineStatus()
172177
versions = h.versions()
178+
builds = h.buildTimes()
173179
cols = []*header{
174180
{name: colTarget},
175181
{name: colMemUsed},
@@ -181,8 +187,9 @@ func newTableTargets(ts StstMap, smap *meta.Smap, units string) *Table {
181187
{name: colUptime},
182188
{name: colPodName, hide: len(pods) == 1 && pods[0] == ""},
183189
{name: colStatus, hide: len(status) == 1 && status[0] == NodeOnline},
184-
{name: colVersion, hide: len(versions) == 1 && len(ts) > 1},
185-
{name: colBuildTime, hide: len(versions) == 1 && len(ts) > 1}, // intended
190+
{name: colVersion, hide: len(versions) == 1 && len(builds) == 1},
191+
{name: colBuildTime, hide: len(versions) == 1 && len(builds) == 1},
192+
{name: colStateFlags, hide: ts.allStateFlagsOK()},
186193
}
187194
table = newTable(cols...)
188195
)
@@ -244,6 +251,7 @@ func newTableTargets(ts StstMap, smap *meta.Smap, units string) *Table {
244251
ds.Status,
245252
ds.Version,
246253
ds.BuildTime,
254+
ds.Cluster.Flags.String(),
247255
}
248256
table.addRow(row)
249257
}

cmd/cli/teb/templates.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const (
5252
indent1 + "Targets:\t{{FormatTargetsSumm .Smap .NumDisks}}\n" +
5353
indent1 + "Capacity:\t{{.Capacity}}\n" +
5454
indent1 + "Cluster Map:\t{{FormatSmap .Smap}}\n" +
55+
indent1 + "Software:\t{{FormatCluSoft .Version .BuildTime}}\n" +
5556
indent1 + "Deployment:\t{{ ( Deployments .Status) }}\n" +
5657
indent1 + "Status:\t{{ ( OnlineStatus .Status) }}\n" +
5758
indent1 + "Rebalance:\t{{ ( Rebalance .Status) }}\n" +
@@ -366,6 +367,8 @@ type (
366367
CluConfig *cmn.ClusterConfig
367368
Status StatsAndStatusHelper
368369
Capacity string
370+
Version string // when all equal
371+
BuildTime string // ditto
369372
NumDisks int
370373
}
371374
ListBucketsHelper struct {
@@ -397,6 +400,7 @@ var (
397400
"FormatObjCustom": fmtObjCustom,
398401
"FormatDaemonID": fmtDaemonID,
399402
"FormatSmap": fmtSmap,
403+
"FormatCluSoft": fmtCluSoft,
400404
"FormatProxiesSumm": fmtProxiesSumm,
401405
"FormatTargetsSumm": fmtTargetsSumm,
402406
"FormatCapPctMAM": fmtCapPctMAM,
@@ -530,3 +534,12 @@ func (h *StatsAndStatusHelper) toSlice(jtag string) []string {
530534
}
531535
return res
532536
}
537+
538+
func (m StstMap) allStateFlagsOK() bool {
539+
for _, ds := range m {
540+
if !ds.Cluster.Flags.IsOK() {
541+
return false
542+
}
543+
}
544+
return true
545+
}

cmd/cli/teb/utils.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ func fmtSmap(smap *meta.Smap) string {
177177
return fmt.Sprintf("version %d, UUID %s, primary %s", smap.Version, smap.UUID, smap.Primary.StringEx())
178178
}
179179

180+
func fmtCluSoft(version, build string) string {
181+
if version == "" {
182+
return unknownVal
183+
}
184+
if build == "" {
185+
return version + " (build: " + unknownVal + ")"
186+
}
187+
return version + " (build: " + build + ")"
188+
}
189+
180190
func fmtStringList(lst []string) string {
181191
if len(lst) == 0 {
182192
return unknownVal
File renamed without changes.

0 commit comments

Comments
 (0)