fix: display correct number of machines on dashboard

Rename members to machines to be clearer.
Display the correct member count.

Closes siderolabs/talos#7127.

Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
This commit is contained in:
Utku Ozdemir 2023-04-26 11:08:36 +02:00
parent cad43f0ad3
commit b097efcde2
No known key found for this signature in database
GPG Key ID: 65933E76F0549B0D

View File

@ -17,14 +17,14 @@ import (
)
type talosInfoData struct {
uuid string
clusterName string
stage string
ready string
typ string
numMembersText string
uuid string
clusterName string
stage string
ready string
typ string
numMachinesText string
numMembers int
machineIDSet map[string]struct{}
}
// TalosInfo represents the Talos info widget.
@ -101,12 +101,12 @@ func (widget *TalosInfo) updateNodeData(data resourcedata.Data) {
}
case *cluster.Member:
if data.Deleted {
nodeData.numMembers--
delete(nodeData.machineIDSet, res.Metadata().ID())
} else {
nodeData.numMembers++
nodeData.machineIDSet[res.Metadata().ID()] = struct{}{}
}
nodeData.numMembersText = strconv.Itoa(nodeData.numMembers)
nodeData.numMachinesText = strconv.Itoa(len(nodeData.machineIDSet))
}
}
@ -114,12 +114,13 @@ func (widget *TalosInfo) getOrCreateNodeData(node string) *talosInfoData {
nodeData, ok := widget.nodeMap[node]
if !ok {
nodeData = &talosInfoData{
uuid: notAvailable,
clusterName: notAvailable,
stage: notAvailable,
ready: notAvailable,
typ: notAvailable,
numMembersText: notAvailable,
uuid: notAvailable,
clusterName: notAvailable,
stage: notAvailable,
ready: notAvailable,
typ: notAvailable,
numMachinesText: notAvailable,
machineIDSet: make(map[string]struct{}),
}
widget.nodeMap[node] = nodeData
@ -154,8 +155,8 @@ func (widget *TalosInfo) redraw() {
Value: data.typ,
},
{
Name: "MEMBERS",
Value: data.numMembersText,
Name: "MACHINES",
Value: data.numMachinesText,
},
},
}