You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
klog.V(2).InfoS("The clusterResourcePlacement does not have an external rollout strategy", "clusterResourcePlacement", placementName, "clusterStagedUpdateRun", updateRunRef)
79
-
return"", fmt.Errorf("%w: %s", errInitializedFailed, "parent clusterResourcePlacement does not have an external rollout strategy, current strategy: "+string(crp.Spec.Strategy.Type))
80
+
wrongRolloutTypeErr:=controller.NewUserError(fmt.Errorf("parent clusterResourcePlacement does not have an external rollout strategy, current strategy: "+string(crp.Spec.Strategy.Type)))
returnnil, nil, controller.NewUnexpectedBehaviorError(fmt.Errorf("binding `%s`'s state %s is not scheduled or bound", binding.Name, binding.Spec.State))
178
+
stateErr:=fmt.Errorf("binding `%s`'s state %s is not scheduled or bound", binding.Name, binding.Spec.State)
klog.ErrorS(err, "Failed to get StagedUpdateStrategy", "stagedUpdateStrategy", updateRun.Spec.StagedUpdateStrategyName, "clusterStagedUpdateRun", updateRunRef)
207
212
ifapierrors.IsNotFound(err) {
208
213
// we won't continue or retry the initialization if the StagedUpdateStrategy is not found.
209
-
returnfmt.Errorf("%w: %s", errInitializedFailed, "referenced clusterStagedUpdateStrategy not found: "+updateRun.Spec.StagedUpdateStrategyName)
214
+
strategyNotFoundErr:=controller.NewUserError(fmt.Errorf("referenced clusterStagedUpdateStrategy not found: "+updateRun.Spec.StagedUpdateStrategyName))
klog.ErrorS(err, "Failed to validate the after stage tasks", "clusterStagedUpdateStrategy", updateStrategyName, "stage name", stage.Name, "clusterStagedUpdateRun", updateRunRef)
257
263
// no more retries here.
258
-
returnfmt.Errorf("%w: the after stage tasks are invalid, clusterStagedUpdateStrategy: %s, stage: %s, err: %s", errInitializedFailed, updateStrategyName, stage.Name, err.Error())
264
+
invalidAfterStageErr:=controller.NewUserError(fmt.Errorf("the after stage tasks are invalid, clusterStagedUpdateStrategy: %s, stage: %s, err: %s", updateStrategyName, stage.Name, err.Error()))
klog.ErrorS(err, "Failed to list clusters for the stage", "clusterStagedUpdateStrategy", updateStrategyName, "stage name", stage.Name, "labelSelector", stage.LabelSelector, "clusterStagedUpdateRun", updateRunRef)
273
281
// list err can be retried.
274
-
returnerr
282
+
returncontroller.NewAPIServerError(true, err)
275
283
}
276
284
277
285
// Intersect the selected clusters with the clusters in the stage.
278
286
for_, cluster:=rangeclusterList.Items {
279
287
if_, ok:=allSelectedClusters[cluster.Name]; ok {
280
288
if_, ok:=allPlacedClusters[cluster.Name]; ok {
281
289
// a cluster can only appear in one stage.
282
-
dupErr:=fmt.Errorf("cluster `%s` appears in more than one stages", cluster.Name)
290
+
dupErr:=controller.NewUserError(fmt.Errorf("cluster `%s` appears in more than one stages", cluster.Name))
283
291
klog.ErrorS(dupErr, "Failed to compute the stage", "clusterStagedUpdateStrategy", updateStrategyName, "stage name", stage.Name, "clusterStagedUpdateRun", updateRunRef)
keyErr:=fmt.Errorf("the sorting label `%s:%s` on cluster `%s` is not valid: %s", *stage.SortingLabelKey, cluster.Labels[*stage.SortingLabelKey], cluster.Name, err.Error())
298
+
keyErr:=controller.NewUserError(fmt.Errorf("the sorting label `%s:%s` on cluster `%s` is not valid: %s", *stage.SortingLabelKey, cluster.Labels[*stage.SortingLabelKey], cluster.Name, err.Error()))
291
299
klog.ErrorS(keyErr, "Failed to sort clusters in the stage", "clusterStagedUpdateStrategy", updateStrategyName, "stage name", stage.Name, "clusterStagedUpdateRun", updateRunRef)
missingErr:=fmt.Errorf("some clusters are not placed in any stage")
348
+
missingErr:=controller.NewUserError(fmt.Errorf("some clusters are not placed in any stage"))
341
349
forcluster:=rangeallSelectedClusters {
342
350
if_, ok:=allPlacedClusters[cluster]; !ok {
343
351
klog.ErrorS(missingErr, "Cluster is missing in any stage", "cluster", cluster, "clusterStagedUpdateStrategy", updateStrategyName, "clusterStagedUpdateRun", updateRunRef)
klog.ErrorS(err, "Failed to get the master resource snapshot", "resourceSnapshot", updateRun.Spec.ResourceSnapshotIndex, "clusterStagedUpdateRun", updateRunRef)
374
382
ifapierrors.IsNotFound(err) {
375
-
snapshotNotFoundErr:=fmt.Errorf("resource snapshot `%s` not found", updateRun.Spec.ResourceSnapshotIndex)
383
+
snapshotNotFoundErr:=controller.NewUserError(fmt.Errorf("resource snapshot `%s` not found", updateRun.Spec.ResourceSnapshotIndex))
376
384
// we won't continue or retry the initialization if the resource snapshot is not found.
wrongCRPErr:=fmt.Errorf("resource snapshot `%s` is not associated with expected clusterResourcePlacement `%s`, got: `%s`", updateRun.Spec.ResourceSnapshotIndex, placementName, parentCRP)
392
+
wrongCRPErr:=controller.NewUserError(fmt.Errorf("resource snapshot `%s` is not associated with expected clusterResourcePlacement `%s`, got: `%s`", updateRun.Spec.ResourceSnapshotIndex, placementName, parentCRP))
385
393
klog.ErrorS(wrongCRPErr, "Failed to get the master resource snapshot", "resourceSnapshot", updateRun.Spec.ResourceSnapshotIndex, "clusterStagedUpdateRun", updateRunRef)
nomasterErr:=fmt.Errorf("resource snapshot `%s` is not a master snapshot", updateRun.Spec.ResourceSnapshotIndex)
399
+
nomasterErr:=controller.NewUserError(fmt.Errorf("resource snapshot `%s` is not a master snapshot", updateRun.Spec.ResourceSnapshotIndex))
392
400
klog.ErrorS(nomasterErr, "Failed to get the master resource snapshot", "resourceSnapshot", updateRun.Spec.ResourceSnapshotIndex, "clusterStagedUpdateRun", updateRunRef)
0 commit comments