Skip to content

Commit

Permalink
Resolve Deppy error check todo
Browse files Browse the repository at this point in the history
We already have a version which contains the fix
and can revert to a simpler check.

Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
  • Loading branch information
m1kola committed Nov 10, 2023
1 parent bf39dc7 commit 088c9b7
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions internal/controllers/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,13 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
return ctrl.Result{}, err
}

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

// lookup the bundle in the solution that corresponds to the
Expand Down Expand Up @@ -472,7 +466,12 @@ func operatorRequestsForCatalog(c client.Reader, logger logr.Logger) handler.Map
// and joins them with a semicolon (rather than a comma, which the unsat.Error()
// function does). This function also has the side effect of sorting the items
// in the unsat slice.
func prettyUnsatMessage(unsat deppy.NotSatisfiable) string {
func prettyUnsatMessage(err error) string {
unsat := deppy.NotSatisfiable{}
if !errors.As(err, &unsat) {
panic("we must always receive deppy.NotSatisfiable here")
}

sort.Slice(unsat, func(i, j int) bool {
return unsat[i].String() < unsat[j].String()
})
Expand Down

0 comments on commit 088c9b7

Please sign in to comment.