Skip to content

Commit

Permalink
refactor: Move cluster paused check to per-cluster reconciliation func
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Mar 14, 2024
1 parent 17bca6e commit 2872f24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 0 additions & 6 deletions controllers/helmchartproxy/helmchartproxy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,6 @@ func (r *HelmChartProxyReconciler) reconcileNormal(ctx context.Context, helmChar
continue
}

// Don't reconcile if the Cluster is paused.
if cluster.Spec.Paused {
log.V(2).Info("Cluster is paused, skipping reconcile", "cluster", cluster.Name)
continue
}

err := r.reconcileForCluster(ctx, helmChartProxy, cluster)
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"sigs.k8s.io/cluster-api-addon-provider-helm/internal"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/annotations"
"sigs.k8s.io/cluster-api/util/conditions"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -57,6 +58,12 @@ func (r *HelmChartProxyReconciler) deleteOrphanedHelmReleaseProxies(ctx context.
func (r *HelmChartProxyReconciler) reconcileForCluster(ctx context.Context, helmChartProxy *addonsv1alpha1.HelmChartProxy, cluster clusterv1.Cluster) error {
log := ctrl.LoggerFrom(ctx)

// Don't reconcile if the Cluster or the helmChartProxy is paused.
if annotations.IsPaused(&cluster, helmChartProxy) {
log.V(2).Info("Reconciliation is paused for this Cluster", "cluster", cluster.Name)
return nil
}

existingHelmReleaseProxy, err := r.getExistingHelmReleaseProxy(ctx, helmChartProxy, &cluster)
if err != nil {
// TODO: Should we set a condition here?
Expand Down

0 comments on commit 2872f24

Please sign in to comment.