Skip to content

Commit 4d8edfd

Browse files
committed
set Validation to False if Policy conflict found
Signed-off-by: rakeshgm <[email protected]>
1 parent e70da08 commit 4d8edfd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

internal/controller/drpolicy_controller.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ func (r *DRPolicyReconciler) reconcile(
157157
// we will be able to validate conflicts only after PeerClass is updated
158158
err := validatePolicyConflicts(u.ctx, r.APIReader, u.object, drclusters)
159159
if err != nil {
160-
return ctrl.Result{}, fmt.Errorf("%s: %w", ReasonValidationFailed, err) // we can change the message later.
160+
return ctrl.Result{}, fmt.Errorf("DRPolicy conflict found: %w",
161+
u.validatedSetFalse("DRPolicyConflictFound", err))
161162
}
162163

163164
if err := u.validatedSetTrue("Succeeded", "drpolicy validated"); err != nil {
@@ -295,7 +296,7 @@ func hasConflictingDRPolicy(match *ramen.DRPolicy, drclusters *ramen.DRClusterLi
295296

296297
// None of the common managed clusters should belong to Metro Regions in either of the drpolicies.
297298
if haveOverlappingMetroZones(match, drp, drclusters) {
298-
return fmt.Errorf("drpolicy: %v has overlapping metro region with another drpolicy %v", match.Name, drp.Name)
299+
return fmt.Errorf("drpolicy: %v has overlapping clusters with another drpolicy %v", match.Name, drp.Name)
299300
}
300301
}
301302

@@ -324,9 +325,9 @@ func getStorageIDsFromPeerClass(drpolicy *ramen.DRPolicy) []string {
324325
return sids
325326
}
326327

327-
func hasCommonClusters(metroMap map[string][]string, commonClusterIDs, commonClusters []string) bool {
328+
func hasCommonClusters(metroMap map[string][]string, commonSIDs, commonClusters []string) bool {
328329
for _, v := range metroMap {
329-
if sets.NewString(v...).HasAny(commonClusterIDs...) {
330+
if sets.NewString(v...).HasAny(commonSIDs...) {
330331
return true
331332
}
332333

0 commit comments

Comments
 (0)