Skip to content

Commit 2092076

Browse files
Merge pull request #30154 from hongkailiu/OTA-1601
OTA-1601: upgrade status: recover checking the updating COs
2 parents 105a7f0 + c42fde3 commit 2092076

File tree

3 files changed

+55
-23
lines changed

3 files changed

+55
-23
lines changed

pkg/monitortests/cli/adm_upgrade/status/controlplane.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
var (
13-
operatorLinePattern = regexp.MustCompile(`^\S+\s+\S+\s+\S+\s+.*$`)
13+
operatorFirstLinePattern = regexp.MustCompile(`^\S+\s+\S+\s+\S+(\s+.*)?$`)
1414
)
1515

1616
func (w *monitor) controlPlane() *junitapi.JUnitTestCase {
@@ -100,20 +100,18 @@ func (w *monitor) controlPlane() *junitapi.JUnitTestCase {
100100
}
101101

102102
items := len(strings.Split(updatingOperators, ","))
103-
// TODO: These should actually exactly match, but `oc adm upgrade status` emits operators with linebreaks in
104-
// messages in a crappy way which we will need to fix
105-
if len(cp.Operators) < items {
103+
if len(cp.Operators) != items {
106104
fail(fmt.Sprintf("Control plane summary contains Updating key with %d operators but operators section has %d items", items, len(cp.Operators)))
107105
continue
108106
}
109107
}
110108

111-
// TODO: `oc adm upgrade status` emits operators with linebreaks in messages in a crappy way which we will need to fix
112-
// for _, operator := range cp.Operators {
113-
// if !operatorLinePattern.MatchString(operator) {
114-
// fail(fmt.Sprintf("Bad line in operators: %s", operator))
115-
// }
116-
// }
109+
for _, operator := range cp.Operators {
110+
firstLine := strings.Split(operator, "\n")[0]
111+
if !operatorFirstLinePattern.MatchString(firstLine) {
112+
fail(fmt.Sprintf("Bad first line in operators: %s", operator))
113+
}
114+
}
117115

118116
for _, node := range cp.Nodes {
119117
if !nodeLinePattern.MatchString(node) {

pkg/monitortests/cli/adm_upgrade/status/controlplane_test.go

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ ip-10-0-111-19.us-west-1.compute.internal Outdated Pending 4.20.0-0.ci-2
9494
SINCE LEVEL IMPACT MESSAGE
9595
8m57s Info None Update is proceeding well`
9696

97-
// TODO: This is a bug in `oc adm upgrade status` that we will fix but for now we need to tolerate
98-
// Eventually we will fail on output like this and we will also need to add a testcase for the fixed output
9997
var operatorsWithLinebreaksInMessages = `Unable to fetch alerts, ignoring alerts in 'Update Health': failed to get alerts from Thanos: no token is currently in use for this session
10098
= Control Plane =
10199
Assessment: Progressing
@@ -106,14 +104,14 @@ Duration: 24m (Est. Time Remaining: 45m)
106104
Operator Health: 34 Healthy
107105
108106
Updating Cluster Operators
109-
NAME SINCE REASON MESSAGE
110-
image-registry 6s DeploymentNotCompleted::NodeCADaemonUnavailable NodeCADaemonProgressing: The daemon set node-ca is deploying node pods
111-
Progressing: The deployment has not completed
112-
monitoring 4s RollOutInProgress Rolling out the stack.
113-
openshift-controller-manager 11s RouteControllerManager_DesiredStateNotYetAchieved::_DesiredStateNotYetAchieved Progressing: deployment/controller-manager: observed generation is 10, desired generation is 11
114-
Progressing: deployment/controller-manager: updated replicas is 1, desired replicas is 3
115-
RouteControllerManagerProgressing: deployment/route-controller-manager: observed generation is 7, desired generation is 8
116-
RouteControllerManagerProgressing: deployment/route-controller-manager: updated replicas is 1, desired replicas is 3
107+
NAME SINCE REASON MESSAGE
108+
image-registry 6s DeploymentNotCo... NodeCADaemonProgressing: The daemon set node-ca is deploying node pods
109+
Progressing: The deployment has not completed
110+
monitoring 4s RollOutInProgre... Rolling out the stack.
111+
openshift-controller-manager 11s RouteController... Progressing: deployment/controller-manager: observed generation is 10, desired generation is 11
112+
Progressing: deployment/controller-manager: updated replicas is 1, desired replicas is 3
113+
RouteControllerManagerProgressing: deployment/route-controller-manager: observed generation is 7, desired generation is 8
114+
RouteControllerManagerProgressing: deployment/route-controller-manager: updated replicas is 1, desired replicas is 3
117115
118116
Control Plane Nodes
119117
NAME ASSESSMENT PHASE VERSION EST MESSAGE
@@ -136,6 +134,28 @@ ip-10-0-64-121.ec2.internal Outdated Pending 4.20.0-0.ci-2025-08-13-1748
136134
SINCE LEVEL IMPACT MESSAGE
137135
24m12s Info None Update is proceeding well`
138136

137+
var operatorsWithEmptyMessage = `Unable to fetch alerts, ignoring alerts in 'Update Health': failed to get alerts from Thanos: no token is currently in use for this session
138+
= Control Plane =
139+
Assessment: Progressing
140+
Target Version: 4.20.0-0.ci-2025-08-26-154705-test-ci-op-jy9dt0lx-latest (from 4.20.0-0.ci-2025-08-26-145530-test-ci-op-jy9dt0lx-initial)
141+
Updating: authentication
142+
Completion: 9% (3 operators updated, 1 updating, 30 waiting)
143+
Duration: 7m27s (Est. Time Remaining: 36m)
144+
Operator Health: 32 Healthy, 1 Unavailable, 1 Available but degraded
145+
146+
Updating Cluster Operators
147+
NAME SINCE REASON MESSAGE
148+
authentication 58s WellKnownReadyCon...
149+
150+
Control Plane Nodes
151+
NAME ASSESSMENT PHASE VERSION EST MESSAGE
152+
ip-10-0-35-68.us-east-2.compute.internal Outdated Pending 4.20.0-0.ci-2025-08-26-145530-test-ci-op-jy9dt0lx-initial ?
153+
154+
= Update Health =
155+
SINCE LEVEL IMPACT MESSAGE
156+
7m27s Info None Update is proceeding well
157+
`
158+
139159
var controlPlaneCompleted = `Unable to fetch alerts, ignoring alerts in 'Update Health': failed to get alerts from Thanos: no token is currently in use for this session
140160
= Control Plane =
141161
Update to 4.20.0-0.ci-2025-08-13-182454-test-ci-op-5wilvz46-latest successfully completed at 2025-08-13T20:33:32Z (duration: 59m)
@@ -238,6 +258,15 @@ func TestMonitor_ControlPlane(t *testing.T) {
238258
Name: "[sig-cli][OCPFeatureGate:UpgradeStatus] oc adm upgrade status control plane section is consistent",
239259
},
240260
},
261+
{
262+
name: "operators section with empty message",
263+
snapshots: []snapshot{
264+
{when: time.Now(), out: operatorsWithEmptyMessage},
265+
},
266+
expected: &junitapi.JUnitTestCase{
267+
Name: "[sig-cli][OCPFeatureGate:UpgradeStatus] oc adm upgrade status control plane section is consistent",
268+
},
269+
},
241270
{
242271
name: "control plane completed",
243272
snapshots: []snapshot{

pkg/monitortests/cli/adm_upgrade/status/outputmodel.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,17 @@ func (p *parser) parseControlPlaneOperators() ([]string, error) {
260260
var operators []string
261261

262262
for {
263-
line, done := p.next()
263+
line, done := p.next(preserveLeadingWhitespace)
264264
if done || line == "" {
265265
break
266266
}
267-
268-
operators = append(operators, line)
267+
trimLeft := strings.TrimLeft(line, " \t")
268+
if len(operators) == 0 || line == trimLeft {
269+
operators = append(operators, line)
270+
} else {
271+
last := len(operators) - 1
272+
operators[last] = fmt.Sprintf("%s\n%s", operators[last], trimLeft)
273+
}
269274
}
270275

271276
if len(operators) == 0 {

0 commit comments

Comments
 (0)