Skip to content

Commit 170974b

Browse files
committed
fixup! Use Helm List operator to determine Deployed status
Signed-off-by: Todd Short <tshort@redhat.com>
1 parent fac9766 commit 170974b

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

internal/controllers/clusterextension_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
291291
// to ensure exponential backoff can occur:
292292
// - Permission errors (it is not possible to watch changes to permissions.
293293
// The only way to eventually recover from permission errors is to keep retrying).
294+
installedBundle = &InstalledBundle{
295+
BundleMetadata: resolvedBundleMetadata,
296+
Image: resolvedBundle.Image,
297+
}
294298
managedObjs, _, err := r.Applier.Apply(ctx, unpackResult.Bundle, ext, objLbls, storeLbls)
295299
if err != nil {
296300
setStatusProgressing(ext, wrapErrorWithResolutionInfo(resolvedBundleMetadata, err))
@@ -299,10 +303,6 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
299303
return ctrl.Result{}, err
300304
}
301305

302-
installedBundle = &InstalledBundle{
303-
BundleMetadata: resolvedBundleMetadata,
304-
Image: resolvedBundle.Image,
305-
}
306306
// Successful install
307307
setInstalledStatusFromBundle(ext, installedBundle, nil)
308308

internal/controllers/clusterextension_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ func TestClusterExtensionResolutionAndUnpackSuccessfulApplierFails(t *testing.T)
322322

323323
t.Log("By checking the status fields")
324324
expectedBundleMetadata := ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}
325-
require.Empty(t, clusterExtension.Status.Install)
325+
require.NotEmpty(t, clusterExtension.Status.Install)
326326

327327
t.Log("By checking the expected installed conditions")
328328
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
@@ -428,8 +428,8 @@ func TestClusterExtensionApplierFailsWithBundleInstalled(t *testing.T) {
428428
t.Log("By checking the expected installed conditions")
429429
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
430430
require.NotNil(t, installedCond)
431-
require.Equal(t, metav1.ConditionTrue, installedCond.Status)
432-
require.Equal(t, ocv1alpha1.ReasonSucceeded, installedCond.Reason)
431+
require.Equal(t, metav1.ConditionFalse, installedCond.Status)
432+
require.Equal(t, ocv1alpha1.ReasonFailed, installedCond.Reason)
433433

434434
t.Log("By checking the expected progressing conditions")
435435
progressingCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeProgressing)

internal/controllers/common_controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ func setInstalledStatusFromBundle(ext *ocv1alpha1.ClusterExtension, installedBun
3535
Bundle: installedBundle.BundleMetadata,
3636
}
3737
setInstallStatus(ext, installStatus)
38-
setInstalledStatusConditionSuccess(ext, fmt.Sprintf("Installed bundle %s successfully", installedBundle.Image))
38+
// If both conditions occur, this is a failed Apply when a bundle was already installed
39+
if err != nil {
40+
setInstalledStatusConditionFailed(ext, err.Error())
41+
} else {
42+
setInstalledStatusConditionSuccess(ext, fmt.Sprintf("Installed bundle %s successfully", installedBundle.Image))
43+
}
3944
return
4045
}
4146
// Nothing is installed, if there's no error, it means no installed bundle was found

0 commit comments

Comments
 (0)