You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pkg/cli/admin/upgrade/recommend: Add a blank line after --version conditional risk
When I added the:
Update to 4.18.6 Recommended=False:
...
block in c1ef328 (pkg/cli/admin/upgrade/recommend: Add --version
option for specific releases, 2024-10-14, #1897), there was no
subsequent output in this "--version has conditional risks" case, so
the earlier lack-of-blank-line made sense.
But then 2d7e004 (pkg/cli/admin/upgrade/recommend: New,
feature-gated --accept, 2025-05-06, #2023) gave the option for a
subsequent:
error: issues that apply to this cluster but which were not included in --accept: ...
or:
Update to %s has no known issues relevant...
This commit adds trackers to all the output blocks in the command for
"was there previous output on this stream?", so that a new block (or a
returned error) can be prefixed by the blank line needed to set off
the new block from the previous block. For example, it now sets off
the error line from the previous, possibly-long message strings:
...
Update to 4.18.6 Recommended=False:
Image: quay.io/openshift-release-dev/ocp-release@sha256:61fdad894f035a8b192647c224faf565279518255bdbf60a91db4ee0479adaa6
Release URL: https://access.redhat.com/errata/RHSA-2025:3066
Reason: CRIOLayerCompressionPulls
Message: The CRI-O container runtime may fail to pull images with certain layer compression characteristics https://issues.redhat.com/browse/OCPNODE-3074
error: issues that apply to this cluster but which were not included in --accept: ConditionalUpdateRisk,KubeContainerWaiting
instead of cramming that 'error: ...' or '... has no known issues...'
right onto the end of the output. The error is getting written to
standard error instead of the standard output, so there's still some
wiggle room for poor spacing for terminal users and others who are
flattening those two streams together.
And now that we have the additional newline handling in recommend.go,
I can drop the newline I'd been manually injecting in examples_test.go
to make the test fixtures more readable. I should have noticed that
test-specific injection as a sign that the better recommend.go newline
handling was useful. Oh well, better late than never.
fmt.Fprintf(o.Out, "%sinfo: An update is in progress. You may wish to let this update complete before requesting a new update.\n %s\n\n", acceptContext, strings.ReplaceAll(c.Message, "\n", "\n "))
186
+
ifpreviousStdout {
187
+
fmt.Fprintln(o.Out)
188
+
}
189
+
fmt.Fprintf(o.Out, "%sinfo: An update is in progress. You may wish to let this update complete before requesting a new update.\n %s\n", acceptContext, strings.ReplaceAll(c.Message, "\n", "\n "))
fmt.Fprintf(o.Out, "The following conditions found no cause for concern in updating this cluster to later releases: %s\n\n", strings.Join(happyConditions, ", "))
225
+
ifpreviousStdout {
226
+
fmt.Fprintln(o.Out)
227
+
}
228
+
fmt.Fprintf(o.Out, "The following conditions found no cause for concern in updating this cluster to later releases: %s\n", strings.Join(happyConditions, ", "))
229
+
previousStdout=true
215
230
}
216
231
iflen(acceptedConditions) >0 {
217
232
sort.Strings(acceptedConditions)
218
-
fmt.Fprintf(o.Out, "The following conditions found cause for concern in updating this cluster to later releases, but were explicitly accepted via --accept: %s\n\n", strings.Join(acceptedConditions, ", "))
233
+
ifpreviousStdout {
234
+
fmt.Fprintln(o.Out)
235
+
}
236
+
fmt.Fprintf(o.Out, "The following conditions found cause for concern in updating this cluster to later releases, but were explicitly accepted via --accept: %s\n", strings.Join(acceptedConditions, ", "))
237
+
previousStdout=true
219
238
}
220
239
iflen(unhappyConditions) >0 {
221
240
sort.Strings(unhappyConditions)
222
-
fmt.Fprintf(o.Out, "The following conditions found cause for concern in updating this cluster to later releases: %s\n\n", strings.Join(unhappyConditions, ", "))
241
+
ifpreviousStdout {
242
+
fmt.Fprintln(o.Out)
243
+
}
244
+
fmt.Fprintf(o.Out, "The following conditions found cause for concern in updating this cluster to later releases: %s\n", strings.Join(unhappyConditions, ", "))
returnfmt.Errorf("no updates to %d available, so cannot display context for the requested release %s", o.version.Major, o.version)
316
373
} elseifminor, ok:=major[o.version.Minor]; !ok {
374
+
ifpreviousStdout {
375
+
fmt.Fprintln(o.Out)
376
+
} elseifpreviousStderr {
377
+
fmt.Fprintln(o.ErrOut)
378
+
}
317
379
returnfmt.Errorf("no updates to %d.%d available, so cannot display context for the requested release %s", o.version.Major, o.version.Minor, o.version)
318
380
} else {
319
381
for_, update:=rangeminor {
320
382
ifupdate.Release.Version==o.version.String() {
321
-
if!o.quiet {
322
-
fmt.Fprintln(o.Out)
323
-
}
324
383
ifc:=notRecommendedCondition(update); c==nil {
325
384
if!o.quiet {
385
+
ifpreviousStdout {
386
+
fmt.Fprintln(o.Out)
387
+
}
326
388
fmt.Fprintf(o.Out, "Update to %s has no known issues relevant to this cluster.\nImage: %s\nRelease URL: %s\n", update.Release.Version, update.Release.Image, update.Release.URL)
389
+
previousStdout=true
327
390
}
328
391
} else {
329
392
if!o.quiet {
330
393
reason:=c.Reason
331
394
ifaccept.Has("ConditionalUpdateRisk") {
332
395
reason=fmt.Sprintf("accepted %s via ConditionalUpdateRisk", c.Reason)
returnfmt.Errorf("issues that apply to this cluster but which were not included in --accept: %s", strings.Join(sets.List(unaccepted), ","))
341
413
} elseifissues.Len() >0&&!o.quiet {
414
+
ifpreviousStdout {
415
+
fmt.Fprintln(o.Out)
416
+
}
342
417
fmt.Fprintf(o.Out, "Update to %s has no known issues relevant to this cluster other than the accepted %s.\n", update.Release.Version, strings.Join(sets.List(issues), ","))
418
+
previousStdout=true
343
419
}
344
420
returnnil
345
421
}
346
422
}
423
+
ifpreviousStdout {
424
+
fmt.Fprintln(o.Out)
425
+
} elseifpreviousStderr {
426
+
fmt.Fprintln(o.ErrOut)
427
+
}
347
428
returnfmt.Errorf("no update to %s available, so cannot display context for the requested release", o.version)
348
429
}
349
430
}
350
431
351
432
iflen(majorMinorBuckets) ==0 {
433
+
ifpreviousStdout {
434
+
fmt.Fprintln(o.Out)
435
+
}
352
436
fmt.Fprintf(o.Out, "No updates available. You may still upgrade to a specific release image with --to-image or wait for new updates to be available.\n")
0 commit comments