Improved cluster stats and INSTALL.md doc

This commit is contained in:
Ben Duncan
2026-02-14 16:19:25 +10:00
parent 774655eff0
commit c5e561abbf
7 changed files with 221 additions and 138 deletions
+25
View File
@@ -831,6 +831,7 @@ func runAdminInitMultiNode(cmd *cobra.Command, accessKey, secretKey, accountID,
PredastoreNodeID: predastoreNodeID,
Services: services,
RemoteNodes: buildRemoteNodes(allNodes, node),
}
// Generate config files
@@ -1134,6 +1135,7 @@ func runAdminJoin(cmd *cobra.Command, args []string) {
PredastoreNodeID: predastoreNodeID,
Services: services,
RemoteNodes: buildRemoteNodes(statusResp.Nodes, node),
}
// Generate config files
@@ -1177,3 +1179,26 @@ func runAdminJoin(cmd *cobra.Command, args []string) {
fmt.Println(" ./scripts/start-dev.sh")
fmt.Println()
}
// buildRemoteNodes converts formation NodeInfo into RemoteNode entries,
// excluding the local node. This puts all cluster members into hive.toml
// so config is the source of truth for expected cluster membership.
func buildRemoteNodes(allNodes map[string]formation.NodeInfo, localNode string) []admin.RemoteNode {
var remote []admin.RemoteNode
for name, n := range allNodes {
if name == localNode {
continue
}
remote = append(remote, admin.RemoteNode{
Name: name,
Host: n.BindIP,
Region: n.Region,
AZ: n.AZ,
Services: n.Services,
})
}
sort.Slice(remote, func(i, j int) bool {
return remote[i].Name < remote[j].Name
})
return remote
}
+10 -3
View File
@@ -162,14 +162,21 @@ func runGetNodes(cmd *cobra.Command, args []string) {
respondedNodes[resp.Node] = resp
}
// Build table: include all known nodes from config, mark non-responders as NotReady
// Build table: union of config-known nodes + NATS responders
tableData := pterm.TableData{
{"NAME", "STATUS", "IP", "REGION", "AZ", "UPTIME", "VMs", "SERVICES"},
}
// Collect and sort node names for stable output
nodeNames := make([]string, 0, len(cfg.Nodes))
// Collect all node names: config + responded (union)
nodeSet := make(map[string]struct{})
for name := range cfg.Nodes {
nodeSet[name] = struct{}{}
}
for name := range respondedNodes {
nodeSet[name] = struct{}{}
}
nodeNames := make([]string, 0, len(nodeSet))
for name := range nodeSet {
nodeNames = append(nodeNames, name)
}
sort.Strings(nodeNames)
+12
View File
@@ -5,6 +5,7 @@ node = "{{.Node}}"
[nodes.{{.Node}}]
node = "{{.Node}}"
host = "{{.BindIP}}"
region = "{{.Region}}"
az = "{{.Az}}"
{{- if .Services}}
@@ -43,4 +44,15 @@ accesskey = "{{.AccessKey}}"
secretkey = "{{.SecretKey}}"
{{- if gt .PredastoreNodeID 0}}
node_id = {{.PredastoreNodeID}}
{{- end}}
{{- range .RemoteNodes}}
[nodes.{{.Name}}]
node = "{{.Name}}"
host = "{{.Host}}"
region = "{{.Region}}"
az = "{{.AZ}}"
{{- if .Services}}
services = [{{range $i, $s := .Services}}{{if $i}}, {{end}}"{{$s}}"{{end}}]
{{- end}}
{{- end}}
+9 -2
View File
@@ -71,9 +71,16 @@ func runTopNodes(cmd *cobra.Command, args []string) {
respondedNodes[resp.Node] = resp
}
// Node resource table
nodeNames := make([]string, 0, len(cfg.Nodes))
// Node resource table: union of config-known nodes + NATS responders
nodeSet := make(map[string]struct{})
for name := range cfg.Nodes {
nodeSet[name] = struct{}{}
}
for name := range respondedNodes {
nodeSet[name] = struct{}{}
}
nodeNames := make([]string, 0, len(nodeSet))
for name := range nodeSet {
nodeNames = append(nodeNames, name)
}
sort.Strings(nodeNames)