Skip to content

Commit

Permalink
Improve failure message
Browse files Browse the repository at this point in the history
Signed-off-by: Atanas Dinov <atanas.dinov@suse.com>
  • Loading branch information
atanasdinov committed Oct 25, 2024
1 parent 18341ca commit 2598913
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions internal/controller/reconcile_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

var (
errMultipleHelmChartResources = fmt.Errorf("multiple HelmChart resources found")
multipleHelmChartsFailureReason = "Unable to upgrade Helm release backed by multiple HelmChart resources"
multipleHelmChartsFailureReason = "Unable to upgrade Helm release '%s' backed by multiple HelmChart resources"
)

func (r *UpgradePlanReconciler) reconcileHelmChart(ctx context.Context, upgradePlan *lifecyclev1alpha1.UpgradePlan, chart *lifecyclev1alpha1.HelmChart) (ctrl.Result, error) {
Expand All @@ -31,7 +31,7 @@ func (r *UpgradePlanReconciler) reconcileHelmChart(ctx context.Context, upgradeP
depState, err := r.upgradeHelmChart(ctx, upgradePlan, &depChart, chartResources)
if err != nil {
if errors.Is(err, errMultipleHelmChartResources) {
setFailedCondition(upgradePlan, conditionType, multipleHelmChartsFailureReason)
setFailedCondition(upgradePlan, conditionType, fmt.Sprintf(multipleHelmChartsFailureReason, depChart.ReleaseName))
return ctrl.Result{Requeue: true}, nil
}

Expand All @@ -50,7 +50,7 @@ func (r *UpgradePlanReconciler) reconcileHelmChart(ctx context.Context, upgradeP
coreState, err := r.upgradeHelmChart(ctx, upgradePlan, chart, chartResources)
if err != nil {
if errors.Is(err, errMultipleHelmChartResources) {
setFailedCondition(upgradePlan, conditionType, multipleHelmChartsFailureReason)
setFailedCondition(upgradePlan, conditionType, fmt.Sprintf(multipleHelmChartsFailureReason, chart.ReleaseName))
return ctrl.Result{Requeue: true}, nil
}

Expand All @@ -74,8 +74,9 @@ func (r *UpgradePlanReconciler) reconcileHelmChart(ctx context.Context, upgradeP
addonState, err := r.upgradeHelmChart(ctx, upgradePlan, &addonChart, chartResources)
if err != nil {
if errors.Is(err, errMultipleHelmChartResources) {
setFailedCondition(upgradePlan, conditionType, multipleHelmChartsFailureReason)
return ctrl.Result{Requeue: true}, nil
r.Recorder.Eventf(upgradePlan, corev1.EventTypeWarning, conditionType,
fmt.Sprintf(multipleHelmChartsFailureReason, addonChart.ReleaseName))
continue
}

return ctrl.Result{}, err
Expand Down

0 comments on commit 2598913

Please sign in to comment.