From 2e92fb6880d955204e4e923d0ab92437e2719974 Mon Sep 17 00:00:00 2001 From: Ekaterina Kazakova Date: Fri, 20 Dec 2024 09:23:55 +0400 Subject: [PATCH] Fix panic in the provider when chartSpec is not set in the Template Closes #818 --- internal/controller/managedcluster_controller.go | 5 ++--- internal/controller/management_controller.go | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/controller/managedcluster_controller.go b/internal/controller/managedcluster_controller.go index 3dcc43ade..ffb983dc0 100644 --- a/internal/controller/managedcluster_controller.go +++ b/internal/controller/managedcluster_controller.go @@ -312,9 +312,8 @@ func (r *ManagedClusterReconciler) updateCluster(ctx context.Context, mc *hmc.Ma }, ChartRef: clusterTpl.Status.ChartRef, } - reconcileInterval := clusterTpl.Spec.Helm.ChartSpec.Interval.Duration - if reconcileInterval != 0 { - hrReconcileOpts.ReconcileInterval = &reconcileInterval + if clusterTpl.Spec.Helm.ChartSpec != nil { + hrReconcileOpts.ReconcileInterval = &clusterTpl.Spec.Helm.ChartSpec.Interval.Duration } hr, _, err := helm.ReconcileHelmRelease(ctx, r.Client, mc.Name, mc.Namespace, hrReconcileOpts) diff --git a/internal/controller/management_controller.go b/internal/controller/management_controller.go index 8e43c0137..1331ddf94 100644 --- a/internal/controller/management_controller.go +++ b/internal/controller/management_controller.go @@ -149,9 +149,8 @@ func (r *ManagementReconciler) Update(ctx context.Context, management *hmc.Manag TargetNamespace: component.targetNamespace, CreateNamespace: component.createNamespace, } - reconcileInterval := template.Spec.Helm.ChartSpec.Interval.Duration - if reconcileInterval != 0 { - hrReconcileOpts.ReconcileInterval = &reconcileInterval + if template.Spec.Helm.ChartSpec != nil { + hrReconcileOpts.ReconcileInterval = &template.Spec.Helm.ChartSpec.Interval.Duration } if _, _, err := helm.ReconcileHelmRelease(ctx, r.Client, component.helmReleaseName, r.SystemNamespace, hrReconcileOpts); err != nil {