Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion pkg/cli/admin/upgrade/recommend/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func TestExamples(t *testing.T) {
if err := opts.Complete(nil, nil, nil); err != nil {
t.Fatalf("Error when completing options: %v", err)
}
opts.precheckEnabled = true

var stdout, stderr bytes.Buffer
opts.Out = &stdout
Expand Down
73 changes: 34 additions & 39 deletions pkg/cli/admin/upgrade/recommend/recommend.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ type options struct {

mockData mockData
showOutdatedReleases bool
precheckEnabled bool

// quiet configures the verbosity of output. When 'quiet' is true and 'version' is set, only print unaccepted issue names.
quiet bool
Expand Down Expand Up @@ -134,8 +133,6 @@ func (o *options) Complete(f kcmdutil.Factory, cmd *cobra.Command, args []string
}
}

o.precheckEnabled = true

return nil
}

Expand Down Expand Up @@ -188,47 +185,45 @@ func (o *options) Run(ctx context.Context) error {
issues.Insert(string(configv1.OperatorProgressing))
}

if o.precheckEnabled {
conditions, err := o.precheck(ctx)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub doesn't seem to have a knob like Git's -w / --ignore-all-space, but here's the diff rendered that way, to show that I'm just dropping that level of indentation:

$ git --no-pager show --oneline -w
cb28d2778 (HEAD -> remove-obsolete-precheckEnabled, wking/remove-obsolete-precheckEnabled) pkg/cli/admin/upgrade/recommend: Drop obsolete precheckEnabled knob
... 
@@ -188,7 +185,6 @@ func (o *options) Run(ctx context.Context) error {
                issues.Insert(string(configv1.OperatorProgressing))
        }
 
-       if o.precheckEnabled {
        conditions, err := o.precheck(ctx)
        if err != nil {
                if !o.quiet {
@@ -232,7 +228,6 @@ func (o *options) Run(ctx context.Context) error {
                        }
                }
        }
-       }
 
        if c := findClusterOperatorStatusCondition(cv.Status.Conditions, configv1.RetrievedUpdates); c != nil && c.Status != configv1.ConditionTrue {
                if !o.quiet {

Copy link
Member

@petr-muller petr-muller Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the "Hide whitespace" here

Image

if err != nil {
if !o.quiet {
fmt.Fprintf(o.Out, "Failed to check for at least some preconditions: %v\n", err)
}
issues.Insert("FailedToCompletePrecheck")
}
var happyConditions []string
var acceptedConditions []string
var unhappyConditions []string
for _, condition := range conditions {
if condition.Status == metav1.ConditionTrue {
happyConditions = append(happyConditions, fmt.Sprintf("%s (%s)", condition.Type, condition.Reason))
conditions, err := o.precheck(ctx)
if err != nil {
if !o.quiet {
fmt.Fprintf(o.Out, "Failed to check for at least some preconditions: %v\n", err)
}
issues.Insert("FailedToCompletePrecheck")
}
var happyConditions []string
var acceptedConditions []string
var unhappyConditions []string
for _, condition := range conditions {
if condition.Status == metav1.ConditionTrue {
happyConditions = append(happyConditions, fmt.Sprintf("%s (%s)", condition.Type, condition.Reason))
} else {
issues.Insert(condition.acceptanceName)
if accept.Has(condition.acceptanceName) {
acceptedConditions = append(acceptedConditions, condition.Type)
} else {
issues.Insert(condition.acceptanceName)
if accept.Has(condition.acceptanceName) {
acceptedConditions = append(acceptedConditions, condition.Type)
} else {
unhappyConditions = append(unhappyConditions, condition.Type)
}
unhappyConditions = append(unhappyConditions, condition.Type)
}
}
}

if !o.quiet {
if len(happyConditions) > 0 {
sort.Strings(happyConditions)
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, ", "))
}
if len(acceptedConditions) > 0 {
sort.Strings(acceptedConditions)
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, ", "))
}
if len(unhappyConditions) > 0 {
sort.Strings(unhappyConditions)
fmt.Fprintf(o.Out, "The following conditions found cause for concern in updating this cluster to later releases: %s\n\n", strings.Join(unhappyConditions, ", "))
if !o.quiet {
if len(happyConditions) > 0 {
sort.Strings(happyConditions)
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, ", "))
}
if len(acceptedConditions) > 0 {
sort.Strings(acceptedConditions)
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, ", "))
}
if len(unhappyConditions) > 0 {
sort.Strings(unhappyConditions)
fmt.Fprintf(o.Out, "The following conditions found cause for concern in updating this cluster to later releases: %s\n\n", strings.Join(unhappyConditions, ", "))

for _, c := range conditions {
if c.Status != metav1.ConditionTrue {
fmt.Fprintf(o.Out, "%s=%s:\n\n Reason: %s\n Message: %s\n\n", c.Type, c.Status, c.Reason, strings.ReplaceAll(c.Message, "\n", "\n "))
}
for _, c := range conditions {
if c.Status != metav1.ConditionTrue {
fmt.Fprintf(o.Out, "%s=%s:\n\n Reason: %s\n Message: %s\n\n", c.Type, c.Status, c.Reason, strings.ReplaceAll(c.Message, "\n", "\n "))
}
}
}
Expand Down