Skip to content

Commit

Permalink
Fetch only policies for specific drcluster
Browse files Browse the repository at this point in the history
Signed-off-by: Elena Gershkovich <[email protected]>
  • Loading branch information
ELENAGER authored and BenamarMk committed Mar 4, 2024
1 parent cae74b9 commit 8059902
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions controllers/drplacementcontrol_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,37 +470,39 @@ func DRPCsFailingOverToCluster(k8sclient client.Client, log logr.Logger, drclust

drpcCollections := make([]DRPCAndPolicy, 0)

for drpolicyIdx, drpolicy := range drpolicies.Items {
drClusters, err := getDRClusters(context.TODO(), k8sclient, &drpolicies.Items[drpolicyIdx])
if err != nil || len(drClusters) <= 1 {
log.Error(err, "Failed to get DRClusters")

return nil, err
}

// Skip if policy is of type metro, fake the from and to cluster
if metro, _ := dRPolicySupportsMetro(&drpolicies.Items[drpolicyIdx], drClusters); metro {
log.Info("Sync DRPolicy detected, skipping!")

continue
}
for drpolicyIdx := range drpolicies.Items {
drpolicy := &drpolicies.Items[drpolicyIdx]

for _, specCluster := range drpolicy.Spec.DRClusters {
if specCluster != drcluster {
continue
}

drClusters, err := getDRClusters(context.TODO(), k8sclient, drpolicy)
if err != nil || len(drClusters) <= 1 {
log.Error(err, "Failed to get DRClusters")

return nil, err
}

// Skip if policy is of type metro, fake the from and to cluster
if metro, _ := dRPolicySupportsMetro(drpolicy, drClusters); metro {
log.Info("Sync DRPolicy detected, skipping!")

break
}

log.Info("Processing DRPolicy referencing DRCluster", "drpolicy", drpolicy.GetName())

drpcs, err := DRPCsFailingOverToClusterForPolicy(k8sclient, log, &drpolicies.Items[drpolicyIdx], drcluster)
drpcs, err := DRPCsFailingOverToClusterForPolicy(k8sclient, log, drpolicy, drcluster)
if err != nil {
return nil, err
}

for idx := range drpcs {
dprcCollection := DRPCAndPolicy{
drpc: drpcs[idx],
drPolicy: &drpolicies.Items[drpolicyIdx],
drPolicy: drpolicy,
}

drpcCollections = append(drpcCollections, dprcCollection)
Expand Down

0 comments on commit 8059902

Please sign in to comment.