Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Truncate long reasons
  • Loading branch information
hongkailiu committed Aug 14, 2025
commit a35266244500c8d01d5c78e029b033bee9f46681
13 changes: 12 additions & 1 deletion pkg/cli/admin/upgrade/status/controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func (d *controlPlaneStatusDisplayData) Write(f io.Writer, detailed bool, now ti
if i == 0 {
_, _ = table.Write([]byte(o.Name + "\t"))
_, _ = table.Write([]byte(shortDuration(now.Sub(o.Condition.LastTransitionTime.Time)) + "\t"))
_, _ = table.Write([]byte(reason + "\t"))
_, _ = table.Write([]byte(ellipsis(reason, 20) + "\t"))
_, _ = table.Write([]byte(line + "\n"))
} else {
_, _ = table.Write([]byte("\t\t\t" + line + "\n"))
Expand All @@ -517,6 +517,17 @@ func (d *controlPlaneStatusDisplayData) Write(f io.Writer, detailed bool, now ti
return nil
}

func ellipsis(s string, maxLen int) string {
runes := []rune(s)
if len(runes) <= maxLen {
return s
}
if maxLen < 3 {
maxLen = 3
}
return string(runes[0:maxLen-3]) + "..."
}

const controlPlaneStatusTemplateRaw = `= Control Plane =
Assessment: {{ .Assessment }}
Target Version: {{ .TargetVersion }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Duration: 2m54s (Est. Time Remaining: 1h9m)
Operator Health: 32 Healthy, 1 Available but degraded

Updating Cluster Operators
NAME SINCE REASON MESSAGE
kube-apiserver 2m NodeInstaller::PetrDoesNotLikeLongLines::WhichTakeTooMuchSpace NodeInstallerProgressing: 1 node is at revision 8; 0 nodes have achieved new revision 10
Test line breaks
New line
NAME SINCE REASON MESSAGE
kube-apiserver 2m NodeInstaller::Pe... NodeInstallerProgressing: 1 node is at revision 8; 0 nodes have achieved new revision 10
Test line breaks
New line

Control Plane Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
Expand Down