Skip to content

Commit

Permalink
fixup! Use Helm List operator to determine Deployed status
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Short <tshort@redhat.com>
  • Loading branch information
tmshort committed Oct 21, 2024
1 parent 8b12d4e commit 59a0f83
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
8 changes: 4 additions & 4 deletions internal/controllers/clusterextension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
// to ensure exponential backoff can occur:
// - Permission errors (it is not possible to watch changes to permissions.
// The only way to eventually recover from permission errors is to keep retrying).
installedBundle = &InstalledBundle{
BundleMetadata: resolvedBundleMetadata,
Image: resolvedBundle.Image,
}
managedObjs, _, err := r.Applier.Apply(ctx, unpackResult.Bundle, ext, objLbls, storeLbls)
if err != nil {
setStatusProgressing(ext, wrapErrorWithResolutionInfo(resolvedBundleMetadata, err))
Expand All @@ -299,10 +303,6 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
return ctrl.Result{}, err
}

installedBundle = &InstalledBundle{
BundleMetadata: resolvedBundleMetadata,
Image: resolvedBundle.Image,
}
// Successful install
setInstalledStatusFromBundle(ext, installedBundle, nil)

Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/clusterextension_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func TestClusterExtensionResolutionAndUnpackSuccessfulApplierFails(t *testing.T)

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

t.Log("By checking the expected installed conditions")
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
Expand Down Expand Up @@ -428,8 +428,8 @@ func TestClusterExtensionApplierFailsWithBundleInstalled(t *testing.T) {
t.Log("By checking the expected installed conditions")
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
require.NotNil(t, installedCond)
require.Equal(t, metav1.ConditionTrue, installedCond.Status)
require.Equal(t, ocv1alpha1.ReasonSucceeded, installedCond.Reason)
require.Equal(t, metav1.ConditionFalse, installedCond.Status)
require.Equal(t, ocv1alpha1.ReasonFailed, installedCond.Reason)

t.Log("By checking the expected progressing conditions")
progressingCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeProgressing)
Expand Down
7 changes: 6 additions & 1 deletion internal/controllers/common_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ func setInstalledStatusFromBundle(ext *ocv1alpha1.ClusterExtension, installedBun
Bundle: installedBundle.BundleMetadata,
}
setInstallStatus(ext, installStatus)
setInstalledStatusConditionSuccess(ext, fmt.Sprintf("Installed bundle %s successfully", installedBundle.Image))
// If both conditions occur, this is a failed Apply when a bundle was already installed
if err != nil {
setInstalledStatusConditionFailed(ext, err.Error())
} else {
setInstalledStatusConditionSuccess(ext, fmt.Sprintf("Installed bundle %s successfully", installedBundle.Image))
}
return
}
// Nothing is installed, if there's no error, it means no installed bundle was found
Expand Down

0 comments on commit 59a0f83

Please sign in to comment.