Skip to content

Commit 3373785

Browse files
authored
Resolve Deppy error check todo (#535)
We already have a version which contains the fix and can revert to a simpler check. Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
1 parent ec65861 commit 3373785

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

internal/controllers/operator_controller.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,13 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
138138
return ctrl.Result{}, err
139139
}
140140

141-
// TODO: Checking for unsat is awkward using the current version of deppy.
142-
// This awkwardness has been fixed in an unreleased version of deppy.
143-
// When there is a new minor release of deppy, we can revisit this and
144-
// simplify this to a normal error check.
145-
// See https://github.com/operator-framework/deppy/issues/139.
146-
unsat := deppy.NotSatisfiable{}
147-
if ok := errors.As(solution.Error(), &unsat); ok && len(unsat) > 0 {
141+
if err := solution.Error(); err != nil {
148142
op.Status.InstalledBundleResource = ""
149143
setInstalledStatusConditionUnknown(&op.Status.Conditions, "installation has not been attempted as resolution is unsatisfiable", op.GetGeneration())
150144
op.Status.ResolvedBundleResource = ""
151-
msg := prettyUnsatMessage(unsat)
145+
msg := prettyUnsatMessage(err)
152146
setResolvedStatusConditionFailed(&op.Status.Conditions, msg, op.GetGeneration())
153-
return ctrl.Result{}, unsat
147+
return ctrl.Result{}, err
154148
}
155149

156150
// lookup the bundle in the solution that corresponds to the
@@ -472,7 +466,14 @@ func operatorRequestsForCatalog(c client.Reader, logger logr.Logger) handler.Map
472466
// and joins them with a semicolon (rather than a comma, which the unsat.Error()
473467
// function does). This function also has the side effect of sorting the items
474468
// in the unsat slice.
475-
func prettyUnsatMessage(unsat deppy.NotSatisfiable) string {
469+
func prettyUnsatMessage(err error) string {
470+
unsat := deppy.NotSatisfiable{}
471+
if !errors.As(err, &unsat) {
472+
// This function is specifically for formatting deppy.NotSatisfiable.
473+
// Just return default format if the error is something else.
474+
return err.Error()
475+
}
476+
476477
sort.Slice(unsat, func(i, j int) bool {
477478
return unsat[i].String() < unsat[j].String()
478479
})

0 commit comments

Comments
 (0)