@@ -46,6 +46,7 @@ import (
46
46
"k8s.io/apimachinery/pkg/runtime/schema"
47
47
"k8s.io/apimachinery/pkg/types"
48
48
utilerrors "k8s.io/apimachinery/pkg/util/errors"
49
+ "k8s.io/apimachinery/pkg/util/sets"
49
50
apimachyaml "k8s.io/apimachinery/pkg/util/yaml"
50
51
ctrl "sigs.k8s.io/controller-runtime"
51
52
"sigs.k8s.io/controller-runtime/pkg/cache"
@@ -63,6 +64,7 @@ import (
63
64
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
64
65
helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"
65
66
"github.com/operator-framework/operator-registry/alpha/declcfg"
67
+ "github.com/operator-framework/operator-registry/alpha/property"
66
68
rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2"
67
69
helmpredicate "github.com/operator-framework/rukpak/pkg/helm-operator-plugins/predicate"
68
70
rukpaksource "github.com/operator-framework/rukpak/pkg/source"
@@ -106,6 +108,8 @@ type ClusterExtensionReconciler struct {
106
108
//+kubebuilder:rbac:groups=catalogd.operatorframework.io,resources=catalogs,verbs=list;watch
107
109
//+kubebuilder:rbac:groups=catalogd.operatorframework.io,resources=catalogmetadata,verbs=list;watch
108
110
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.
109
113
func (r * ClusterExtensionReconciler ) Reconcile (ctx context.Context , req ctrl.Request ) (ctrl.Result , error ) {
110
114
l := log .FromContext (ctx ).WithName ("operator-controller" )
111
115
l .V (1 ).Info ("starting" )
@@ -220,6 +224,12 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
220
224
return r .handleResolutionErrors (ext , err )
221
225
}
222
226
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
+
223
233
bundleVersion , err := bundle .Version ()
224
234
if err != nil {
225
235
ext .Status .ResolvedBundle = nil
@@ -302,7 +312,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
302
312
303
313
rel , state , err := r .getReleaseState (ac , ext , chrt , values , post )
304
314
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 )
306
316
return ctrl.Result {}, err
307
317
}
308
318
@@ -343,14 +353,14 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
343
353
344
354
relObjects , err := util .ManifestObjects (strings .NewReader (rel .Manifest ), fmt .Sprintf ("%s-release-manifest" , rel .Name ))
345
355
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 )
347
357
return ctrl.Result {}, err
348
358
}
349
359
350
360
for _ , obj := range relObjects {
351
361
uMap , err := runtime .DefaultUnstructuredConverter .ToUnstructured (obj )
352
362
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 )
354
364
return ctrl.Result {}, err
355
365
}
356
366
@@ -372,7 +382,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
372
382
return nil
373
383
}(); err != nil {
374
384
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 )
376
386
return ctrl.Result {}, err
377
387
}
378
388
}
@@ -804,3 +814,22 @@ func bundleMetadataFor(bundle *catalogmetadata.Bundle) *ocv1alpha1.BundleMetadat
804
814
Version : ver .String (),
805
815
}
806
816
}
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