@@ -46,6 +46,7 @@ import (
4646 "k8s.io/apimachinery/pkg/runtime/schema"
4747 "k8s.io/apimachinery/pkg/types"
4848 utilerrors "k8s.io/apimachinery/pkg/util/errors"
49+ "k8s.io/apimachinery/pkg/util/sets"
4950 apimachyaml "k8s.io/apimachinery/pkg/util/yaml"
5051 ctrl "sigs.k8s.io/controller-runtime"
5152 "sigs.k8s.io/controller-runtime/pkg/cache"
@@ -63,6 +64,7 @@ import (
6364 catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
6465 helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"
6566 "github.com/operator-framework/operator-registry/alpha/declcfg"
67+ "github.com/operator-framework/operator-registry/alpha/property"
6668 rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2"
6769 helmpredicate "github.com/operator-framework/rukpak/pkg/helm-operator-plugins/predicate"
6870 rukpaksource "github.com/operator-framework/rukpak/pkg/source"
@@ -106,6 +108,8 @@ type ClusterExtensionReconciler struct {
106108//+kubebuilder:rbac:groups=catalogd.operatorframework.io,resources=catalogs,verbs=list;watch
107109//+kubebuilder:rbac:groups=catalogd.operatorframework.io,resources=catalogmetadata,verbs=list;watch
108110
111+ // The operator controller needs to watch all the bundle objects and reconcile accordingly. Though not ideal, but these permissions are required.
112+ // This has been taken from rukpak, and an issue was created before to discuss it: https://github.com/operator-framework/rukpak/issues/800.
109113func (r * ClusterExtensionReconciler ) Reconcile (ctx context.Context , req ctrl.Request ) (ctrl.Result , error ) {
110114 l := log .FromContext (ctx ).WithName ("operator-controller" )
111115 l .V (1 ).Info ("starting" )
@@ -220,6 +224,12 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
220224 return r .handleResolutionErrors (ext , err )
221225 }
222226
227+ if err := r .validateBundle (bundle ); err != nil {
228+ setInstalledStatusConditionFailed (& ext .Status .Conditions , err .Error (), ext .GetGeneration ())
229+ setDeprecationStatusesUnknown (& ext .Status .Conditions , "deprecation checks have not been attempted as installation has failed" , ext .GetGeneration ())
230+ return ctrl.Result {}, err
231+ }
232+
223233 bundleVersion , err := bundle .Version ()
224234 if err != nil {
225235 ext .Status .ResolvedBundle = nil
@@ -302,7 +312,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
302312
303313 rel , state , err := r .getReleaseState (ac , ext , chrt , values , post )
304314 if err != nil {
305- setInstalledStatusConditionFailed (& ext .Status .Conditions , fmt .Sprintf ("%s:%v" , ocv1alpha1 .ReasonErrorGettingReleaseState , err ), ext .Generation )
315+ setInstalledStatusConditionFailed (& ext .Status .Conditions , fmt .Sprintf ("%s:%v" , rukpakv1alpha2 .ReasonErrorGettingReleaseState , err ), ext .Generation )
306316 return ctrl.Result {}, err
307317 }
308318
@@ -343,14 +353,14 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
343353
344354 relObjects , err := util .ManifestObjects (strings .NewReader (rel .Manifest ), fmt .Sprintf ("%s-release-manifest" , rel .Name ))
345355 if err != nil {
346- setInstalledStatusConditionFailed (& ext .Status .Conditions , fmt .Sprintf ("%s:%v" , ocv1alpha1 .ReasonCreateDynamicWatchFailed , err ), ext .Generation )
356+ setInstalledStatusConditionFailed (& ext .Status .Conditions , fmt .Sprintf ("%s:%v" , rukpakv1alpha2 .ReasonCreateDynamicWatchFailed , err ), ext .Generation )
347357 return ctrl.Result {}, err
348358 }
349359
350360 for _ , obj := range relObjects {
351361 uMap , err := runtime .DefaultUnstructuredConverter .ToUnstructured (obj )
352362 if err != nil {
353- setInstalledStatusConditionFailed (& ext .Status .Conditions , fmt .Sprintf ("%s:%v" , ocv1alpha1 .ReasonCreateDynamicWatchFailed , err ), ext .Generation )
363+ setInstalledStatusConditionFailed (& ext .Status .Conditions , fmt .Sprintf ("%s:%v" , rukpakv1alpha2 .ReasonCreateDynamicWatchFailed , err ), ext .Generation )
354364 return ctrl.Result {}, err
355365 }
356366
@@ -372,7 +382,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
372382 return nil
373383 }(); err != nil {
374384 ext .Status .InstalledBundle = nil
375- setInstalledStatusConditionFailed (& ext .Status .Conditions , fmt .Sprintf ("%s:%v" , ocv1alpha1 .ReasonCreateDynamicWatchFailed , err ), ext .Generation )
385+ setInstalledStatusConditionFailed (& ext .Status .Conditions , fmt .Sprintf ("%s:%v" , rukpakv1alpha2 .ReasonCreateDynamicWatchFailed , err ), ext .Generation )
376386 return ctrl.Result {}, err
377387 }
378388 }
@@ -804,3 +814,22 @@ func bundleMetadataFor(bundle *catalogmetadata.Bundle) *ocv1alpha1.BundleMetadat
804814 Version : ver .String (),
805815 }
806816}
817+
818+ func (r * ClusterExtensionReconciler ) validateBundle (bundle * catalogmetadata.Bundle ) error {
819+ unsupportedProps := sets .New (
820+ property .TypePackageRequired ,
821+ property .TypeGVKRequired ,
822+ property .TypeConstraint ,
823+ )
824+ for i := range bundle .Properties {
825+ if unsupportedProps .Has (bundle .Properties [i ].Type ) {
826+ return fmt .Errorf (
827+ "bundle %q has a dependency declared via property %q which is currently not supported" ,
828+ bundle .Name ,
829+ bundle .Properties [i ].Type ,
830+ )
831+ }
832+ }
833+
834+ return nil
835+ }
0 commit comments