Skip to content

Commit ccbc50b

Browse files
committed
feat(omnictl): show node name and locked status in cluster status
The `omnictl cluster status` tree listed machines by UUID only, while the Talos/Kubernetes upgrade status messages referenced the friendly Kubernetes node name, making it hard to correlate which machine a status line was about. A locked machine was also only surfaced when it additionally had a pending config update. Render the node name (from the ClusterMachineStatusLabelNodeName label already on the resource) in parentheses after the UUID, and show a dedicated "Locked" indicator whenever the MachineLocked annotation is set, e.g. `Machine "0000...edb"(omni-foo-abcdef) Running Ready Locked`. Machines that have not yet joined Kubernetes show no node name rather than empty parentheses. Closes #1700 Signed-off-by: Fritz Schaal <fritz.schaal@siderolabs.com>
1 parent 3edf383 commit ccbc50b

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

client/pkg/template/operations/internal/statustree/helpers.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,23 @@ func clusterMachineStageString(phase specs.ClusterMachineStatusSpec_Stage) strin
139139
return c(phaseString)
140140
}
141141

142+
func clusterMachineNodeNameString(clusterMachine *omni.ClusterMachineStatus) string {
143+
nodename, _ := clusterMachine.Metadata().Labels().Get(omni.ClusterMachineStatusLabelNodeName)
144+
if nodename == "" {
145+
return ""
146+
}
147+
148+
return color.CyanString("(%s)", nodename)
149+
}
150+
151+
func clusterMachineLockedString(clusterMachine *omni.ClusterMachineStatus) string {
152+
if _, locked := clusterMachine.Metadata().Annotations().Get(omni.MachineLocked); !locked {
153+
return ""
154+
}
155+
156+
return " " + color.BlueString("Locked")
157+
}
158+
142159
func clusterMachineConnected(clusterMachine *omni.ClusterMachineStatus) string {
143160
_, connected := clusterMachine.Metadata().Labels().Get(omni.MachineStatusLabelConnected)
144161
if connected {
@@ -158,7 +175,7 @@ func clusterMachineConfigOutdated(outdated bool) string {
158175

159176
func clusterMachineConfigStatus(node *omni.ClusterMachineStatus) string {
160177
if _, locked := node.Metadata().Labels().Get(omni.UpdateLocked); locked {
161-
return " " + color.BlueString("Pending Config Update (Machine Locked)")
178+
return " " + color.BlueString("Pending Config Update")
162179
}
163180

164181
switch node.TypedSpec().Value.ConfigApplyStatus {

client/pkg/template/operations/internal/statustree/statustree.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ func (t NodeWrapper) String() string {
5858
)
5959
case *omni.ClusterMachineStatus:
6060
return fmt.Sprintf(
61-
"%s %q %s%s%s%s%s",
61+
"%s %q%s %s%s%s%s%s%s",
6262
color.YellowString("Machine"),
6363
node.Metadata().ID(),
64+
clusterMachineNodeNameString(node),
6465
clusterMachineStageString(node.TypedSpec().Value.Stage),
6566
clusterMachineReadyString(node),
6667
clusterMachineConnected(node),
68+
clusterMachineLockedString(node),
6769
clusterMachineConfigOutdated(!node.TypedSpec().Value.ConfigUpToDate),
6870
clusterMachineConfigStatus(node),
6971
)

0 commit comments

Comments
 (0)