@@ -36,6 +36,7 @@ import (
36
36
"helm.sh/helm/v3/pkg/postrender"
37
37
"helm.sh/helm/v3/pkg/release"
38
38
"helm.sh/helm/v3/pkg/storage/driver"
39
+ corev1 "k8s.io/api/core/v1"
39
40
"k8s.io/apimachinery/pkg/api/equality"
40
41
apimeta "k8s.io/apimachinery/pkg/api/meta"
41
42
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -71,10 +72,9 @@ import (
71
72
"github.com/operator-framework/operator-controller/internal/httputil"
72
73
"github.com/operator-framework/operator-controller/internal/labels"
73
74
"github.com/operator-framework/operator-controller/internal/rukpak/bundledeployment"
74
- registryv1handler "github.com/operator-framework/operator-controller/internal/rukpak/handler "
75
+ "github.com/operator-framework/operator-controller/internal/rukpak/convert "
75
76
crdupgradesafety "github.com/operator-framework/operator-controller/internal/rukpak/preflights/crdupgradesafety"
76
77
rukpaksource "github.com/operator-framework/operator-controller/internal/rukpak/source"
77
- "github.com/operator-framework/operator-controller/internal/rukpak/storage"
78
78
"github.com/operator-framework/operator-controller/internal/rukpak/util"
79
79
)
80
80
@@ -88,8 +88,6 @@ type ClusterExtensionReconciler struct {
88
88
BundleProvider BundleProvider
89
89
Unpacker rukpaksource.Unpacker
90
90
ActionClientGetter helmclient.ActionClientGetter
91
- Storage storage.Storage
92
- Handler registryv1handler.Handler
93
91
dynamicWatchMutex sync.RWMutex
94
92
dynamicWatchGVKs sets.Set [schema.GroupVersionKind ]
95
93
controller crcontroller.Controller
@@ -132,6 +130,8 @@ type Preflight interface {
132
130
// This has been taken from rukpak, and an issue was created before to discuss it: https://github.com/operator-framework/rukpak/issues/800.
133
131
func (r * ClusterExtensionReconciler ) Reconcile (ctx context.Context , req ctrl.Request ) (ctrl.Result , error ) {
134
132
l := log .FromContext (ctx ).WithName ("operator-controller" )
133
+ ctx = log .IntoContext (ctx , l )
134
+
135
135
l .V (1 ).Info ("reconcile starting" )
136
136
defer l .V (1 ).Info ("reconcile ending" )
137
137
@@ -212,6 +212,9 @@ func checkForUnexpectedFieldChange(a, b ocv1alpha1.ClusterExtension) bool {
212
212
*/
213
213
//nolint:unparam
214
214
func (r * ClusterExtensionReconciler ) reconcile (ctx context.Context , ext * ocv1alpha1.ClusterExtension ) (ctrl.Result , error ) {
215
+ l := log .FromContext (ctx )
216
+
217
+ l .V (1 ).Info ("handling finalizers" )
215
218
finalizeResult , err := r .Finalizers .Finalize (ctx , ext )
216
219
if err != nil {
217
220
// TODO: For now, this error handling follows the pattern of other error handling.
@@ -232,6 +235,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
232
235
}
233
236
234
237
// run resolution
238
+ l .V (1 ).Info ("resolving bundle" )
235
239
bundle , err := r .resolve (ctx , * ext )
236
240
if err != nil {
237
241
// Note: We don't distinguish between resolution-specific errors and generic errors
@@ -242,6 +246,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
242
246
return ctrl.Result {}, err
243
247
}
244
248
249
+ l .V (1 ).Info ("validating bundle" )
245
250
if err := r .validateBundle (bundle ); err != nil {
246
251
ext .Status .ResolvedBundle = nil
247
252
ext .Status .InstalledBundle = nil
@@ -269,6 +274,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
269
274
// Note: The BundleDeployment here is not a k8s API, its a simple Go struct which
270
275
// necessary embedded values.
271
276
bd := r .generateBundleDeploymentForUnpack (ctx , bundle .Image , ext )
277
+ l .V (1 ).Info ("unpacking resolved bundle" )
272
278
unpackResult , err := r .Unpacker .Unpack (ctx , bd )
273
279
if err != nil {
274
280
setStatusUnpackFailed (ext , err .Error ())
@@ -282,31 +288,22 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
282
288
283
289
return ctrl.Result {}, nil
284
290
case rukpaksource .StateUnpacked :
285
- // TODO: Add finalizer to clean the stored bundles, after https://github.com/operator-framework/rukpak/pull/897
286
- // merges.
287
- if err := r .Storage .Store (ctx , ext .GetName (), unpackResult .Bundle ); err != nil {
288
- setStatusUnpackFailed (ext , err .Error ())
289
- return ctrl.Result {}, err
290
- }
291
291
setStatusUnpacked (ext , fmt .Sprintf ("unpack successful: %v" , unpackResult .Message ))
292
292
default :
293
293
setStatusUnpackFailed (ext , "unexpected unpack status" )
294
294
// We previously exit with a failed status if error is not nil.
295
295
return ctrl.Result {}, fmt .Errorf ("unexpected unpack status: %v" , unpackResult .Message )
296
296
}
297
297
298
- bundleFS , err := r .Storage .Load (ctx , ext .GetName ())
299
- if err != nil {
300
- setInstalledStatusConditionFailed (ext , err .Error ())
301
- return ctrl.Result {}, err
302
- }
303
-
304
- chrt , values , err := r .Handler .Handle (ctx , bundleFS , bd )
298
+ l .V (1 ).Info ("converting bundle to helm chart" )
299
+ chrt , err := convert .RegistryV1ToHelmChart (ctx , unpackResult .Bundle , ext .Spec .InstallNamespace , []string {corev1 .NamespaceAll })
305
300
if err != nil {
306
301
setInstalledStatusConditionFailed (ext , err .Error ())
307
302
return ctrl.Result {}, err
308
303
}
304
+ values := chartutil.Values {}
309
305
306
+ l .V (1 ).Info ("getting helm client" )
310
307
ac , err := r .ActionClientGetter .ActionClientFor (ctx , ext )
311
308
if err != nil {
312
309
ext .Status .InstalledBundle = nil
@@ -324,12 +321,14 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
324
321
},
325
322
}
326
323
324
+ l .V (1 ).Info ("getting current state of helm release" )
327
325
rel , desiredRel , state , err := r .getReleaseState (ac , ext , chrt , values , post )
328
326
if err != nil {
329
327
setInstalledStatusConditionFailed (ext , fmt .Sprintf ("%s:%v" , ocv1alpha1 .ReasonErrorGettingReleaseState , err ))
330
328
return ctrl.Result {}, err
331
329
}
332
330
331
+ l .V (1 ).Info ("running preflight checks" )
333
332
for _ , preflight := range r .Preflights {
334
333
if ext .Spec .Preflight != nil && ext .Spec .Preflight .CRDUpgradeSafety != nil {
335
334
if _ , ok := preflight .(* crdupgradesafety.Preflight ); ok && ext .Spec .Preflight .CRDUpgradeSafety .Disabled {
@@ -354,6 +353,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
354
353
}
355
354
}
356
355
356
+ l .V (1 ).Info ("reconciling helm release changes" )
357
357
switch state {
358
358
case stateNeedsInstall :
359
359
rel , err = ac .Install (ext .GetName (), ext .Spec .InstallNamespace , chrt , values , func (install * action.Install ) error {
@@ -384,6 +384,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
384
384
return ctrl.Result {}, fmt .Errorf ("unexpected release state %q" , state )
385
385
}
386
386
387
+ l .V (1 ).Info ("configuring watches for release objects" )
387
388
relObjects , err := util .ManifestObjects (strings .NewReader (rel .Manifest ), fmt .Sprintf ("%s-release-manifest" , rel .Name ))
388
389
if err != nil {
389
390
setInstalledStatusConditionFailed (ext , fmt .Sprintf ("%s:%v" , ocv1alpha1 .ReasonCreateDynamicWatchFailed , err ))
0 commit comments