Skip to content

Commit bde282b

Browse files
committed
only show top 10 missing clusters
Signed-off-by: Wantong Jiang <[email protected]>
1 parent cc97c3a commit bde282b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pkg/controllers/updaterun/initialization.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,11 @@ func (r *Reconciler) computeRunStageStatus(
389389
}
390390
// Sort the missing clusters by their names to generate a stable error message.
391391
sort.Strings(missingClusters)
392-
missingClustersStr := strings.Join(missingClusters, ", ")
393-
klog.ErrorS(missingErr, "Clusters are missing in any stage", "clusters", missingClustersStr, "clusterStagedUpdateStrategy", updateStrategyName, "clusterStagedUpdateRun", updateRunRef)
392+
klog.ErrorS(missingErr, "Clusters are missing in any stage", "clusters", strings.Join(missingClusters, ", "), "clusterStagedUpdateStrategy", updateStrategyName, "clusterStagedUpdateRun", updateRunRef)
393+
// Only show the first 10 missing clusters in the CRP status.
394+
missingClusters = missingClusters[:min(10, len(missingClusters))]
394395
// no more retries here.
395-
return fmt.Errorf("%w: %s: %s", errInitializedFailed, missingErr.Error(), missingClustersStr)
396+
return fmt.Errorf("%w: %s (showing up to 10): %s", errInitializedFailed, missingErr.Error(), strings.Join(missingClusters, ", "))
396397
}
397398
return nil
398399
}

pkg/controllers/updaterun/initialization_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ var _ = Describe("Updaterun initialization tests", func() {
617617
Expect(k8sClient.Create(ctx, updateRun)).To(Succeed())
618618

619619
By("Validating the initialization failed")
620-
validateFailedInitCondition(ctx, updateRun, "some clusters are not placed in any stage: cluster-0, cluster-2, cluster-4, cluster-6, cluster-8")
620+
validateFailedInitCondition(ctx, updateRun, "some clusters are not placed in any stage (showing up to 10): cluster-0, cluster-2, cluster-4, cluster-6, cluster-8")
621621
})
622622

623623
It("Should select all scheduled clusters if labelSelector is empty and select no clusters if labelSelector is nil", func() {

0 commit comments

Comments
 (0)