@@ -201,6 +201,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
201
201
setInstallStatus (ext , nil )
202
202
setResolutionStatus (ext , nil )
203
203
setResolvedStatusConditionFailed (ext , err .Error ())
204
+ setStatusProgressing (ext , err )
204
205
ensureAllConditionsWithReason (ext , ocv1alpha1 .ReasonFailed , err .Error ())
205
206
return ctrl.Result {}, err
206
207
}
@@ -216,6 +217,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
216
217
setInstallStatus (ext , nil )
217
218
// TODO: use Installed=Unknown
218
219
setInstalledStatusConditionFailed (ext , err .Error ())
220
+ setStatusProgressing (ext , err )
219
221
return ctrl.Result {}, err
220
222
}
221
223
@@ -227,6 +229,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
227
229
setInstallStatus (ext , nil )
228
230
setResolutionStatus (ext , nil )
229
231
setResolvedStatusConditionFailed (ext , err .Error ())
232
+ setStatusProgressing (ext , err )
230
233
ensureAllConditionsWithReason (ext , ocv1alpha1 .ReasonFailed , err .Error ())
231
234
return ctrl.Result {}, err
232
235
}
@@ -247,8 +250,9 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
247
250
// all catalogs?
248
251
SetDeprecationStatus (ext , resolvedBundle .Name , resolvedDeprecation )
249
252
253
+ resolvedBundleMetadata := bundleutil .MetadataFor (resolvedBundle .Name , * resolvedBundleVersion )
250
254
resStatus := & ocv1alpha1.ClusterExtensionResolutionStatus {
251
- Bundle : bundleutil . MetadataFor ( resolvedBundle . Name , * resolvedBundleVersion ) ,
255
+ Bundle : resolvedBundleMetadata ,
252
256
}
253
257
setResolutionStatus (ext , resStatus )
254
258
setResolvedStatusConditionSuccess (ext , fmt .Sprintf ("resolved to %q" , resolvedBundle .Image ))
@@ -264,20 +268,18 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
264
268
unpackResult , err := r .Unpacker .Unpack (ctx , bundleSource )
265
269
if err != nil {
266
270
setStatusUnpackFailed (ext , err .Error ())
271
+ // Wrap the error passed to this with the resolution information until we have successfully
272
+ // installed since we intend for the progressing condition to replace the resolved condition
273
+ // and will be removing the .status.resolution field from the ClusterExtension status API
274
+ setStatusProgressing (ext , wrapErrorWithResolutionInfo (resolvedBundleMetadata , err ))
267
275
return ctrl.Result {}, err
268
276
}
269
277
270
278
switch unpackResult .State {
271
- case rukpaksource .StatePending :
272
- setStatusUnpackFailed (ext , unpackResult .Message )
273
- ensureAllConditionsWithReason (ext , ocv1alpha1 .ReasonFailed , "unpack pending" )
274
- return ctrl.Result {}, nil
275
279
case rukpaksource .StateUnpacked :
276
280
setStatusUnpacked (ext , unpackResult .Message )
277
281
default :
278
- setStatusUnpackFailed (ext , "unexpected unpack status" )
279
- // We previously exit with a failed status if error is not nil.
280
- return ctrl.Result {}, fmt .Errorf ("unexpected unpack status: %v" , unpackResult .Message )
282
+ panic (fmt .Sprintf ("unexpected unpack state %q" , unpackResult .State ))
281
283
}
282
284
283
285
objLbls := map [string ]string {
@@ -304,25 +306,36 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
304
306
managedObjs , _ , err := r .Applier .Apply (ctx , unpackResult .Bundle , ext , objLbls , storeLbls )
305
307
if err != nil {
306
308
setInstalledStatusConditionFailed (ext , err .Error ())
309
+ setStatusProgressing (ext , wrapErrorWithResolutionInfo (resolvedBundleMetadata , err ))
307
310
return ctrl.Result {}, err
308
311
}
309
312
310
313
installStatus := & ocv1alpha1.ClusterExtensionInstallStatus {
311
- Bundle : bundleutil . MetadataFor ( resolvedBundle . Name , * resolvedBundleVersion ) ,
314
+ Bundle : resolvedBundleMetadata ,
312
315
}
313
316
setInstallStatus (ext , installStatus )
314
317
setInstalledStatusConditionSuccess (ext , fmt .Sprintf ("Installed bundle %s successfully" , resolvedBundle .Image ))
315
318
316
319
l .V (1 ).Info ("watching managed objects" )
317
320
cache , err := r .Manager .Get (ctx , ext )
318
321
if err != nil {
322
+ // No need to wrap error with resolution information here (or beyond) since the
323
+ // bundle was successfully installed and the information will be present in
324
+ // the .status.installed field
325
+ setStatusProgressing (ext , err )
319
326
return ctrl.Result {}, err
320
327
}
321
328
322
329
if err := cache .Watch (ctx , r .controller , managedObjs ... ); err != nil {
330
+ setStatusProgressing (ext , err )
323
331
return ctrl.Result {}, err
324
332
}
325
333
334
+ // If we made it here, we have successfully reconciled the ClusterExtension
335
+ // and have reached the desired state. Since the Progressing status should reflect
336
+ // our progress towards the desired state, we also set it when we have reached
337
+ // the desired state by providing a nil error value.
338
+ setStatusProgressing (ext , nil )
326
339
return ctrl.Result {}, nil
327
340
}
328
341
@@ -438,6 +451,10 @@ func (r *ClusterExtensionReconciler) SetupWithManager(mgr ctrl.Manager) error {
438
451
return nil
439
452
}
440
453
454
+ func wrapErrorWithResolutionInfo (resolved ocv1alpha1.BundleMetadata , err error ) error {
455
+ return fmt .Errorf ("%w for resolved bundle %q with version %q" , err , resolved .Name , resolved .Version )
456
+ }
457
+
441
458
// Generate reconcile requests for all cluster extensions affected by a catalog change
442
459
func clusterExtensionRequestsForCatalog (c client.Reader , logger logr.Logger ) crhandler.MapFunc {
443
460
return func (ctx context.Context , _ client.Object ) []reconcile.Request {
0 commit comments