Skip to content

Commit

Permalink
Merge pull request #864 from gianlucam76/dry-run-reconciliations
Browse files Browse the repository at this point in the history
(perf) ClusterSummary in DryRun mode
  • Loading branch information
gianlucam76 authored Nov 30, 2024
2 parents b3b0e95 + e980bad commit 67a9bcd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 21 additions & 0 deletions controllers/clustersummary_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ const (
// normalRequeueAfter is how long to wait before checking again to see if the cluster can be moved
// to ready after or workload features (for instance ingress or reporter) have failed
normalRequeueAfter = 10 * time.Second

// dryRunRequeueAfter is how long to wait before reconciling a ClusterSummary in DryRun mode
dryRunRequeueAfter = 20 * time.Second
)

type ReportMode int
Expand Down Expand Up @@ -383,6 +386,13 @@ func (r *ClusterSummaryReconciler) reconcileNormal(
}

logger.V(logs.LogInfo).Info("Reconciling ClusterSummary success")

if clusterSummaryScope.IsDryRunSync() {
r.resetFeatureStatusToProvisioning(clusterSummaryScope)
// we need to keep retrying in DryRun ClusterSummaries
return reconcile.Result{Requeue: true, RequeueAfter: dryRunRequeueAfter}, nil
}

return reconcile.Result{}, nil
}

Expand Down Expand Up @@ -1318,3 +1328,14 @@ func (r *ClusterSummaryReconciler) cleanupQueuedCleanOperations(clusterSummary *
r.Deployer.CleanupEntries(clusterSummary.Spec.ClusterNamespace, clusterSummary.Spec.ClusterName, clusterSummary.Name,
string(configv1beta1.FeatureResources), clusterSummary.Spec.ClusterType, true)
}

// resetFeatureStatusToProvisioning reset status from Provisioned to Provisioning
func (r *ClusterSummaryReconciler) resetFeatureStatusToProvisioning(clusterSummaryScope *scope.ClusterSummaryScope) {
status := configv1beta1.FeatureStatusProvisioning
for i := range clusterSummaryScope.ClusterSummary.Status.FeatureSummaries {
fs := &clusterSummaryScope.ClusterSummary.Status.FeatureSummaries[i]
if fs.Status == configv1beta1.FeatureStatusProvisioned {
fs.Status = status
}
}
}
4 changes: 0 additions & 4 deletions controllers/handlers_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ func deployResources(ctx context.Context, c client.Client,
return err
}

if clusterSummary.Spec.ClusterProfileSpec.SyncMode == configv1beta1.SyncModeDryRun {
return &configv1beta1.DryRunReconciliationError{}
}

if deployError != nil {
return deployError
}
Expand Down

0 comments on commit 67a9bcd

Please sign in to comment.