Skip to content

Commit 1c54ec0

Browse files
Merge pull request #2077 from hongkailiu/OTA-1601
OTA-1601: Better the Updating Cluster Operators table
2 parents b999d98 + 5f1dbb8 commit 1c54ec0

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

pkg/cli/admin/upgrade/status/controlplane.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,17 @@ func (d *controlPlaneStatusDisplayData) Write(f io.Writer, detailed bool, now ti
498498
if reason == "" {
499499
reason = "-"
500500
}
501+
lines := strings.Split(o.Condition.Message, "\n")
501502
_, _ = table.Write([]byte(o.Name + "\t"))
502503
_, _ = table.Write([]byte(shortDuration(now.Sub(o.Condition.LastTransitionTime.Time)) + "\t"))
503-
_, _ = table.Write([]byte(reason + "\t"))
504-
_, _ = table.Write([]byte(o.Condition.Message + "\n"))
504+
_, _ = table.Write([]byte(ellipsis(reason, 20) + "\t"))
505+
for i, line := range lines {
506+
if i == 0 {
507+
_, _ = table.Write([]byte(line + "\n"))
508+
} else {
509+
_, _ = table.Write([]byte("\t\t\t" + line + "\n"))
510+
}
511+
}
505512
}
506513
if err := table.Flush(); err != nil {
507514
return err
@@ -510,6 +517,17 @@ func (d *controlPlaneStatusDisplayData) Write(f io.Writer, detailed bool, now ti
510517
return nil
511518
}
512519

520+
func ellipsis(s string, maxLen int) string {
521+
runes := []rune(s)
522+
if len(runes) <= maxLen {
523+
return s
524+
}
525+
if maxLen < 3 {
526+
maxLen = 3
527+
}
528+
return string(runes[0:maxLen-3]) + "..."
529+
}
530+
513531
const controlPlaneStatusTemplateRaw = `= Control Plane =
514532
Assessment: {{ .Assessment }}
515533
Target Version: {{ .TargetVersion }}

pkg/cli/admin/upgrade/status/examples/4.16.0-single-node-co.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,9 +1252,11 @@ items:
12521252
status: "False"
12531253
type: Degraded
12541254
- lastTransitionTime: "2024-08-05T15:58:26Z"
1255-
message: 'NodeInstallerProgressing: 1 node is at revision 8; 0 nodes have achieved
1256-
new revision 10'
1257-
reason: NodeInstaller
1255+
message: |-
1256+
NodeInstallerProgressing: 1 node is at revision 8; 0 nodes have achieved new revision 10
1257+
Test line breaks
1258+
New line
1259+
reason: NodeInstaller::PetrDoesNotLikeLongLines::WhichTakeTooMuchSpace
12581260
status: "True"
12591261
type: Progressing
12601262
- lastTransitionTime: "2024-08-05T15:22:32Z"

pkg/cli/admin/upgrade/status/examples/4.16.0-single-node.detailed-output

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ Duration: 2m54s (Est. Time Remaining: 1h9m)
77
Operator Health: 32 Healthy, 1 Available but degraded
88

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

1315
Control Plane Nodes
1416
NAME ASSESSMENT PHASE VERSION EST MESSAGE

0 commit comments

Comments
 (0)