Skip to content

Commit

Permalink
fix: check for unsat resolutions in Reconcile
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
  • Loading branch information
joelanford committed Aug 22, 2023
1 parent fd7cfb5 commit 79c11b9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/controllers/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ package controllers

import (
"context"
"errors"
"fmt"

"github.com/go-logr/logr"
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
"github.com/operator-framework/deppy/pkg/deppy"
"github.com/operator-framework/deppy/pkg/deppy/solver"
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
"k8s.io/apimachinery/pkg/api/equality"
Expand Down Expand Up @@ -136,6 +138,20 @@ 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 {
op.Status.InstalledBundleResource = ""
setInstalledStatusConditionUnknown(&op.Status.Conditions, "installation has not been attempted as resolution is unsatisfiable", op.GetGeneration())
op.Status.ResolvedBundleResource = ""
setResolvedStatusConditionFailed(&op.Status.Conditions, unsat.Error(), op.GetGeneration())
return ctrl.Result{}, err

Check warning on line 152 in internal/controllers/operator_controller.go

View check run for this annotation

Codecov / codecov/patch

internal/controllers/operator_controller.go#L148-L152

Added lines #L148 - L152 were not covered by tests
}

// lookup the bundle entity in the solution that corresponds to the
// Operator's desired package name.
bundleEntity, err := r.getBundleEntityFromSolution(solution, op.Spec.PackageName)
Expand Down

0 comments on commit 79c11b9

Please sign in to comment.