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 22, 2024
1 parent d950e6e commit 1b55cde
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
12 changes: 6 additions & 6 deletions internal/controllers/clusterextension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,20 @@ 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).
toBeInstalledBundle := &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))
// Now that we're actually trying to install, use the error
setInstalledStatusFromBundle(ext, installedBundle, err)
setInstalledStatusFromBundle(ext, toBeInstalledBundle, err)
return ctrl.Result{}, err
}

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

l.Info("watching managed objects")
cache, err := r.Manager.Get(ctx, ext)
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 1b55cde

Please sign in to comment.