Skip to content

⚠️ Remove Deppy solver #758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2024
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
9 changes: 0 additions & 9 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"

"github.com/operator-framework/deppy/pkg/deppy/solver"

"github.com/operator-framework/operator-controller/internal/catalogmetadata/cache"
catalogclient "github.com/operator-framework/operator-controller/internal/catalogmetadata/client"
"github.com/operator-framework/operator-controller/internal/controllers"
Expand Down Expand Up @@ -93,17 +91,10 @@ func main() {
cl := mgr.GetClient()
catalogClient := catalogclient.New(cl, cache.NewFilesystemCache(cachePath, &http.Client{Timeout: 10 * time.Second}))

resolver, err := solver.New()
if err != nil {
setupLog.Error(err, "unable to create a solver")
os.Exit(1)
}

if err = (&controllers.ClusterExtensionReconciler{
Client: cl,
BundleProvider: catalogClient,
Scheme: mgr.GetScheme(),
Resolver: resolver,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ClusterExtension")
os.Exit(1)
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ require (
github.com/go-logr/logr v1.4.1
github.com/google/go-cmp v0.6.0
github.com/operator-framework/catalogd v0.12.0
github.com/operator-framework/deppy v0.3.0
github.com/operator-framework/operator-registry v1.40.0
github.com/operator-framework/rukpak v0.19.0
github.com/spf13/pflag v1.0.5
Expand All @@ -36,7 +35,6 @@ require (
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-air/gini v1.0.4 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.11.0 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ github.com/evanphx/json-patch/v5 v5.8.0 h1:lRj6N9Nci7MvzrXuX6HFzU8XjmhPiXPlsKEy1
github.com/evanphx/json-patch/v5 v5.8.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-air/gini v1.0.4 h1:lteMAxHKNOAjIqazL/klOJJmxq6YxxSuJ17MnMXny+s=
github.com/go-air/gini v1.0.4/go.mod h1:dd8RvT1xcv6N1da33okvBd8DhMh1/A4siGy6ErjTljs=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
Expand Down Expand Up @@ -105,8 +103,6 @@ github.com/operator-framework/api v0.23.0 h1:kHymOwcHBpBVujT49SKOCd4EVG7Odwj4wl3
github.com/operator-framework/api v0.23.0/go.mod h1:oKcFOz+Xc1UhMi2Pzcp6qsO7wjS4r+yP7EQprQBXrfM=
github.com/operator-framework/catalogd v0.12.0 h1:Cww+CyowkfTFugB9ZjUDpKvumh2vPe/TjCUpMHDmVBM=
github.com/operator-framework/catalogd v0.12.0/go.mod h1:4lryGtBTVOdqlKR0MaVYnlsSOc7HiagVRVo3J4uIo7E=
github.com/operator-framework/deppy v0.3.0 h1:W8wpF0ehcTAdH2WfMyqMPI5Ja0Qv8M5FMO5cXgJvEQ8=
github.com/operator-framework/deppy v0.3.0/go.mod h1:EHDxZz8fKGvuymCng3G/Ou7wuX14GaLr0cmf2u29Oog=
github.com/operator-framework/operator-registry v1.40.0 h1:CaYNE4F/jzahpC7UCILItaIHmB5/oE0sS066nK+5Glw=
github.com/operator-framework/operator-registry v1.40.0/go.mod h1:D2YxapkfRDgjqNTO9d3h3v0DeREbV+8utCLG52zrOy4=
github.com/operator-framework/rukpak v0.19.0 h1:8cW43z4jsvARlsmj2eum5bAsZEvSxqDwfMW3dSq1zq8=
Expand Down
146 changes: 96 additions & 50 deletions internal/controllers/clusterextension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ package controllers
import (
"context"
"fmt"
"sort"
"strings"

mmsemver "github.com/Masterminds/semver/v3"
"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/api/equality"
apimeta "k8s.io/apimachinery/pkg/api/meta"
Expand All @@ -37,22 +39,20 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
"github.com/operator-framework/deppy/pkg/deppy"
"github.com/operator-framework/deppy/pkg/deppy/solver"
"github.com/operator-framework/operator-registry/alpha/declcfg"
rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2"

ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
"github.com/operator-framework/operator-controller/internal/catalogmetadata"
olmvariables "github.com/operator-framework/operator-controller/internal/resolution/variables"
catalogfilter "github.com/operator-framework/operator-controller/internal/catalogmetadata/filter"
catalogsort "github.com/operator-framework/operator-controller/internal/catalogmetadata/sort"
)

// ClusterExtensionReconciler reconciles a ClusterExtension object
type ClusterExtensionReconciler struct {
client.Client
BundleProvider BundleProvider
Scheme *runtime.Scheme
Resolver *solver.Solver
}

//+kubebuilder:rbac:groups=olm.operatorframework.io,resources=clusterextensions,verbs=get;list;watch
Expand Down Expand Up @@ -116,33 +116,8 @@ func checkForUnexpectedFieldChange(a, b ocv1alpha1.ClusterExtension) bool {
//
//nolint:unparam
func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.ClusterExtension) (ctrl.Result, error) {
// gather vars for resolution
vars, err := r.variables(ctx)
if err != nil {
ext.Status.InstalledBundle = nil
setInstalledStatusConditionUnknown(&ext.Status.Conditions, "installation has not been attempted due to failure to gather data for resolution", ext.GetGeneration())
ext.Status.ResolvedBundle = nil
setResolvedStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration())

setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted due to failure to gather data for resolution", ext.GetGeneration())
return ctrl.Result{}, err
}

// run resolution
selection, err := r.Resolver.Solve(vars)
if err != nil {
ext.Status.InstalledBundle = nil
setInstalledStatusConditionUnknown(&ext.Status.Conditions, "installation has not been attempted as resolution failed", ext.GetGeneration())
ext.Status.ResolvedBundle = nil
setResolvedStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration())

setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as resolution failed", ext.GetGeneration())
return ctrl.Result{}, err
}

// lookup the bundle in the solution that corresponds to the
// ClusterExtension's desired package name.
bundle, err := r.bundleFromSolution(selection, ext.Spec.PackageName)
// Lookup the bundle that corresponds to the ClusterExtension's desired package.
bundle, err := r.resolve(ctx, ext)
if err != nil {
ext.Status.InstalledBundle = nil
setInstalledStatusConditionUnknown(&ext.Status.Conditions, "installation has not been attempted as resolution failed", ext.GetGeneration())
Expand Down Expand Up @@ -202,21 +177,105 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
return ctrl.Result{}, nil
}

func (r *ClusterExtensionReconciler) variables(ctx context.Context) ([]deppy.Variable, error) {
func (r *ClusterExtensionReconciler) resolve(ctx context.Context, ext *ocv1alpha1.ClusterExtension) (*catalogmetadata.Bundle, error) {
allBundles, err := r.BundleProvider.Bundles(ctx)
if err != nil {
return nil, err
}
clusterExtensionList := ocv1alpha1.ClusterExtensionList{}
if err := r.Client.List(ctx, &clusterExtensionList); err != nil {

installedBundle, err := r.installedBundle(ctx, allBundles, ext)
Copy link
Member

Choose a reason for hiding this comment

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

At some point, I know we talked about adding some labels or annotations to the BD for the installed package name and version and using that in order to derive successors.

Looking on the removed code in the installed_package variable source, I see that we never made that change. So I think it's fine to stick with that same logic like we are in this PR. But I also think we should capture a follow-up issue (if we don't already have one), to implement the installed bundle detection that way.

Somewhat related: I don't think we should have to find the existing installed bundle in the catalog in order to be able to upgrade from it.

Copy link
Member Author

Choose a reason for hiding this comment

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

At some point, I know we talked about adding some labels or annotations to the BD for the installed package name and version and using that in order to derive successors.

Looking on the removed code in the installed_package variable source, I see that we never made that change. So I think it's fine to stick with that same logic like we are in this PR. But I also think we should capture a follow-up issue (if we don't already have one), to implement the installed bundle detection that way.

@joelanford I can't find the thread in upstream slack, but I think we ended up deciding against using labels and in favour of digests which were supposed to support non-image sources. We have this issue for non-image bundle types support and the idea with digests captured here.

Somewhat related: I don't think we should have to find the existing installed bundle in the catalog in order to be able to upgrade from it.

I might be missing something, but in order to support both server and legacy semantics we seem to need the following data:

  • Package name (for both server and legacy)
  • Current version (for both server and legacy)
  • Bundle name (for legacy)

Now that we have #679 we might be able to get this info from ClusterExtensions's status, but we probably don't want to to read from ClusterExtensions's status while reconciling ClusterExtensions.

Even if we store this data in labels and use on upgrades - it will be an equivalent of looking at ClusterExtensions's status.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed we should not read from ClusterExtension status. I think @varshaprasad96 is planning to include that information as labels on the Helm release secret. Prior to the helm integration landing, we could include that information as BD labels or annotations.

I could have sworn we added BD annotations for that info already, but maybe not.

Copy link
Member Author

Choose a reason for hiding this comment

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

@joelanford I think you did it in your PoC a while ago and I had a draft PR which we then closed in favour of the digest idea, but we didn't get to implement the the digest idea.

if err != nil {
return nil, err
}
bundleDeploymentList := rukpakv1alpha2.BundleDeploymentList{}
if err := r.Client.List(ctx, &bundleDeploymentList); err != nil {

packageName := ext.Spec.PackageName
channelName := ext.Spec.Channel
versionRange := ext.Spec.Version

predicates := []catalogfilter.Predicate[catalogmetadata.Bundle]{
catalogfilter.WithPackageName(packageName),
}

if channelName != "" {
predicates = append(predicates, catalogfilter.InChannel(channelName))
}

if versionRange != "" {
vr, err := mmsemver.NewConstraint(versionRange)
if err != nil {
return nil, fmt.Errorf("invalid version range %q: %w", versionRange, err)
}
predicates = append(predicates, catalogfilter.InMastermindsSemverRange(vr))
}

if ext.Spec.UpgradeConstraintPolicy != ocv1alpha1.UpgradeConstraintPolicyIgnore && installedBundle != nil {
upgradePredicate, err := SuccessorsPredicate(installedBundle)
if err != nil {
return nil, err
}

predicates = append(predicates, upgradePredicate)
}

resultSet := catalogfilter.Filter(allBundles, catalogfilter.And(predicates...))

var upgradeErrorPrefix string
if installedBundle != nil {
installedBundleVersion, err := installedBundle.Version()
if err != nil {
return nil, err
}
upgradeErrorPrefix = fmt.Sprintf("error upgrading from currently installed version %q: ", installedBundleVersion.String())
Copy link
Member

Choose a reason for hiding this comment

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

Nit: upgradeErrorPrefix can be defined as a separate error type globally, and can then be wrapped/formatted to include the bundle version, along with other respective error info like version range, or channel name in the condition. This way it's easier to check for this error with errors.Is for the client.

Copy link
Member Author

Choose a reason for hiding this comment

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

Wrapping errors makes them part of the API and I believe we currently do not have a use case for type checking. I suggest to leave errors opaque and add types, if/when we need them.

}
if len(resultSet) == 0 {
if versionRange != "" && channelName != "" {
return nil, fmt.Errorf("%sno package %q matching version %q found in channel %q", upgradeErrorPrefix, packageName, versionRange, channelName)
}
if versionRange != "" {
return nil, fmt.Errorf("%sno package %q matching version %q found", upgradeErrorPrefix, packageName, versionRange)
}
if channelName != "" {
return nil, fmt.Errorf("%sno package %q found in channel %q", upgradeErrorPrefix, packageName, channelName)
}
return nil, fmt.Errorf("%sno package %q found", upgradeErrorPrefix, packageName)
}
sort.SliceStable(resultSet, func(i, j int) bool {
return catalogsort.ByVersion(resultSet[i], resultSet[j])
})
sort.SliceStable(resultSet, func(i, j int) bool {
return catalogsort.ByDeprecated(resultSet[i], resultSet[j])
})

return resultSet[0], nil
}

func (r *ClusterExtensionReconciler) installedBundle(ctx context.Context, allBundles []*catalogmetadata.Bundle, ext *ocv1alpha1.ClusterExtension) (*catalogmetadata.Bundle, error) {
bd := &rukpakv1alpha2.BundleDeployment{}
err := r.Client.Get(ctx, types.NamespacedName{Name: ext.GetName()}, bd)
if client.IgnoreNotFound(err) != nil {
return nil, err
}

return GenerateVariables(allBundles, clusterExtensionList.Items, bundleDeploymentList.Items)
if bd.Spec.Source.Image == nil || bd.Spec.Source.Image.Ref == "" {
// Bundle not yet installed
return nil, nil
}

bundleImage := bd.Spec.Source.Image.Ref
// find corresponding bundle for the installed content
resultSet := catalogfilter.Filter(allBundles, catalogfilter.And(
catalogfilter.WithPackageName(ext.Spec.PackageName),
catalogfilter.WithBundleImage(bundleImage),
))
if len(resultSet) == 0 {
return nil, fmt.Errorf("bundle with image %q for package %q not found in available catalogs but is currently installed via BundleDeployment %q", bundleImage, ext.Spec.PackageName, bd.Name)
}

sort.SliceStable(resultSet, func(i, j int) bool {
return catalogsort.ByVersion(resultSet[i], resultSet[j])
})

return resultSet[0], nil
}

func mapBDStatusToInstalledCondition(existingTypedBundleDeployment *rukpakv1alpha2.BundleDeployment, ext *ocv1alpha1.ClusterExtension, bundle *catalogmetadata.Bundle) {
Expand Down Expand Up @@ -346,19 +405,6 @@ func SetDeprecationStatus(ext *ocv1alpha1.ClusterExtension, bundle *catalogmetad
}
}

func (r *ClusterExtensionReconciler) bundleFromSolution(selection []deppy.Variable, packageName string) (*catalogmetadata.Bundle, error) {
for _, variable := range selection {
switch v := variable.(type) {
case *olmvariables.BundleVariable:
bundlePkgName := v.Bundle().Package
if packageName == bundlePkgName {
return v.Bundle(), nil
}
}
}
return nil, fmt.Errorf("bundle for package %q not found in solution", packageName)
}

func (r *ClusterExtensionReconciler) GenerateExpectedBundleDeployment(o ocv1alpha1.ClusterExtension, bundlePath string, bundleProvisioner string) *unstructured.Unstructured {
// We use unstructured here to avoid problems of serializing default values when sending patches to the apiserver.
// If you use a typed object, any default values from that struct get serialized into the JSON patch, which could
Expand Down
68 changes: 7 additions & 61 deletions internal/controllers/clusterextension_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestClusterExtensionNonExistentVersion(t *testing.T) {
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionUnknown, cond.Status)
require.Equal(t, ocv1alpha1.ReasonInstallationStatusUnknown, cond.Reason)
require.Equal(t, "installation has not been attempted due to failure to gather data for resolution", cond.Message)
require.Equal(t, "installation has not been attempted as resolution failed", cond.Message)

verifyInvariants(ctx, t, reconciler.Client, clusterExtension)
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
Expand Down Expand Up @@ -608,57 +608,6 @@ func TestClusterExtensionExpectedBundleDeployment(t *testing.T) {
require.NoError(t, cl.DeleteAllOf(ctx, &rukpakv1alpha2.BundleDeployment{}))
}

func TestClusterExtensionDuplicatePackage(t *testing.T) {
cl, reconciler := newClientAndReconciler(t)
ctx := context.Background()
extKey := types.NamespacedName{Name: fmt.Sprintf("cluster-extension-test-%s", rand.String(8))}
const pkgName = "prometheus"

t.Log("When the cluster extension specifies a duplicate package")
t.Log("By initializing cluster state")
dupClusterExtension := &ocv1alpha1.ClusterExtension{
ObjectMeta: metav1.ObjectMeta{Name: fmt.Sprintf("orig-%s", extKey.Name)},
Spec: ocv1alpha1.ClusterExtensionSpec{PackageName: pkgName},
}
require.NoError(t, cl.Create(ctx, dupClusterExtension))

clusterExtension := &ocv1alpha1.ClusterExtension{
ObjectMeta: metav1.ObjectMeta{Name: extKey.Name},
Spec: ocv1alpha1.ClusterExtensionSpec{PackageName: pkgName},
}
require.NoError(t, cl.Create(ctx, clusterExtension))

t.Log("It sets resolution failure status")
t.Log("By running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: extKey})
require.Equal(t, ctrl.Result{}, res)
require.EqualError(t, err, `duplicate identifier "required package prometheus" in input`)

t.Log("By fetching updated cluster extension after reconcile")
require.NoError(t, cl.Get(ctx, extKey, clusterExtension))

t.Log("By checking the status fields")
require.Empty(t, clusterExtension.Status.ResolvedBundle)
require.Empty(t, clusterExtension.Status.InstalledBundle)

t.Log("By checking the expected conditions")
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved)
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionFalse, cond.Status)
require.Equal(t, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
require.Equal(t, `duplicate identifier "required package prometheus" in input`, cond.Message)

cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionUnknown, cond.Status)
require.Equal(t, ocv1alpha1.ReasonInstallationStatusUnknown, cond.Reason)
require.Equal(t, "installation has not been attempted as resolution failed", cond.Message)

verifyInvariants(ctx, t, reconciler.Client, clusterExtension)
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
require.NoError(t, cl.DeleteAllOf(ctx, &rukpakv1alpha2.BundleDeployment{}))
}

func TestClusterExtensionChannelVersionExists(t *testing.T) {
cl, reconciler := newClientAndReconciler(t)
ctx := context.Background()
Expand Down Expand Up @@ -819,7 +768,7 @@ func TestClusterExtensionVersionNoChannel(t *testing.T) {
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionUnknown, cond.Status)
require.Equal(t, ocv1alpha1.ReasonInstallationStatusUnknown, cond.Reason)
require.Equal(t, "installation has not been attempted due to failure to gather data for resolution", cond.Message)
require.Equal(t, "installation has not been attempted as resolution failed", cond.Message)

verifyInvariants(ctx, t, reconciler.Client, clusterExtension)
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
Expand Down Expand Up @@ -867,7 +816,7 @@ func TestClusterExtensionNoChannel(t *testing.T) {
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionUnknown, cond.Status)
require.Equal(t, ocv1alpha1.ReasonInstallationStatusUnknown, cond.Reason)
require.Equal(t, "installation has not been attempted due to failure to gather data for resolution", cond.Message)
require.Equal(t, "installation has not been attempted as resolution failed", cond.Message)

verifyInvariants(ctx, t, reconciler.Client, clusterExtension)
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
Expand Down Expand Up @@ -917,7 +866,7 @@ func TestClusterExtensionNoVersion(t *testing.T) {
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionUnknown, cond.Status)
require.Equal(t, ocv1alpha1.ReasonInstallationStatusUnknown, cond.Reason)
require.Equal(t, "installation has not been attempted due to failure to gather data for resolution", cond.Message)
require.Equal(t, "installation has not been attempted as resolution failed", cond.Message)

verifyInvariants(ctx, t, reconciler.Client, clusterExtension)
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
Expand Down Expand Up @@ -1173,8 +1122,7 @@ func TestClusterExtensionUpgrade(t *testing.T) {
require.NotNil(t, cond)
assert.Equal(t, metav1.ConditionFalse, cond.Status)
assert.Equal(t, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
assert.Contains(t, cond.Message, "constraints not satisfiable")
assert.Regexp(t, "installed package prometheus requires at least one of fake-catalog-prometheus-operatorhub/prometheus/beta/1.2.0, fake-catalog-prometheus-operatorhub/prometheus/beta/1.0.1, fake-catalog-prometheus-operatorhub/prometheus/beta/1.0.0$", cond.Message)
assert.Equal(t, "error upgrading from currently installed version \"1.0.0\": no package \"prometheus\" matching version \"2.0.0\" found in channel \"beta\"", cond.Message)

// Valid update skipping one version
clusterExtension.Spec.Version = "1.2.0"
Expand Down Expand Up @@ -1266,8 +1214,7 @@ func TestClusterExtensionUpgrade(t *testing.T) {
require.NotNil(t, cond)
assert.Equal(t, metav1.ConditionFalse, cond.Status)
assert.Equal(t, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
assert.Contains(t, cond.Message, "constraints not satisfiable")
assert.Contains(t, cond.Message, "installed package prometheus requires at least one of fake-catalog-prometheus-operatorhub/prometheus/beta/1.0.1, fake-catalog-prometheus-operatorhub/prometheus/beta/1.0.0\n")
assert.Equal(t, "error upgrading from currently installed version \"1.0.0\": no package \"prometheus\" matching version \"1.2.0\" found in channel \"beta\"", cond.Message)

// Valid update skipping one version
clusterExtension.Spec.Version = "1.0.1"
Expand Down Expand Up @@ -1458,8 +1405,7 @@ func TestClusterExtensionDowngrade(t *testing.T) {
require.NotNil(t, cond)
assert.Equal(t, metav1.ConditionFalse, cond.Status)
assert.Equal(t, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
assert.Contains(t, cond.Message, "constraints not satisfiable")
assert.Contains(t, cond.Message, "installed package prometheus requires at least one of fake-catalog-prometheus-operatorhub/prometheus/beta/1.2.0, fake-catalog-prometheus-operatorhub/prometheus/beta/1.0.1\n")
assert.Equal(t, "error upgrading from currently installed version \"1.0.1\": no package \"prometheus\" matching version \"1.0.0\" found in channel \"beta\"", cond.Message)
})
}
})
Expand Down
Loading