Skip to content

Commit

Permalink
fix cns register volume controller regression caused by PR-3017 (#3066)
Browse files Browse the repository at this point in the history
  • Loading branch information
divyenpatel authored Sep 26, 2024
1 parent 030e5c5 commit 94709a7
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ func (r *ReconcileCnsRegisterVolume) Reconcile(ctx context.Context,
TopologyRequirement: nil,
Vc: vc})
} else if len(clusterComputeResourceMoIds) > 1 {
// Fetch datastoreAccessibleTopology for the volume in the stretched supervisor cluster
datastoreAccessibleTopology, err = topologyMgr.GetTopologyInfoFromNodes(ctx,
commoncotypes.WCPRetrieveTopologyInfoParams{
DatastoreURL: volume.DatastoreUrl,
Expand All @@ -404,7 +405,6 @@ func (r *ReconcileCnsRegisterVolume) Reconcile(ctx context.Context,
var terms []v1.NodeSelectorTerm
if workloadDomainIsolationEnabled {
for _, topologyTerms := range datastoreAccessibleTopology {

var expressions []v1.NodeSelectorRequirement
for key, value := range topologyTerms {
expressions = append(expressions, v1.NodeSelectorRequirement{
Expand All @@ -417,7 +417,14 @@ func (r *ReconcileCnsRegisterVolume) Reconcile(ctx context.Context,
MatchExpressions: expressions,
})
}
} else {
pvNodeAffinity = &v1.VolumeNodeAffinity{
Required: &v1.NodeSelector{
NodeSelectorTerms: terms,
},
}
} else if len(clusterComputeResourceMoIds) > 1 && len(datastoreAccessibleTopology) == 1 {
// This is the case when workloadDomainIsolation FSS is disabled and
// Supervisor is stretched cluster and we have datastoreAccessibleTopology for the Volume.
matchExpressions := make([]v1.NodeSelectorRequirement, 0)
for key, value := range datastoreAccessibleTopology[0] {
matchExpressions = append(matchExpressions, v1.NodeSelectorRequirement{
Expand All @@ -429,12 +436,11 @@ func (r *ReconcileCnsRegisterVolume) Reconcile(ctx context.Context,
terms = append(terms, v1.NodeSelectorTerm{
MatchExpressions: matchExpressions,
})
}

pvNodeAffinity = &v1.VolumeNodeAffinity{
Required: &v1.NodeSelector{
NodeSelectorTerms: terms,
},
pvNodeAffinity = &v1.VolumeNodeAffinity{
Required: &v1.NodeSelector{
NodeSelectorTerms: terms,
},
}
}
}

Expand Down

0 comments on commit 94709a7

Please sign in to comment.