@@ -93,12 +93,10 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
93
93
// First check if volAvailability is already specified, if not get preferred from Topology
94
94
// Required, in case vol AZ is different from node AZ
95
95
var volAvailability string
96
- if cs .Driver .withTopology {
97
- if volParams ["availability" ] != "" {
98
- volAvailability = volParams ["availability" ]
99
- } else if accessibleTopologyReq != nil {
100
- volAvailability = sharedcsi .GetAZFromTopology (topologyKey , accessibleTopologyReq )
101
- }
96
+ if volParams ["availability" ] != "" {
97
+ volAvailability = volParams ["availability" ]
98
+ } else if accessibleTopologyReq != nil && cs .Driver .withTopology {
99
+ volAvailability = sharedcsi .GetAZFromTopology (topologyKey , accessibleTopologyReq )
102
100
}
103
101
104
102
// get the PVC annotation
@@ -119,7 +117,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
119
117
return nil , status .Error (codes .AlreadyExists , "Volume Already exists with same name and different capacity" )
120
118
}
121
119
klog .V (4 ).Infof ("Volume %s already exists in Availability Zone: %s of size %d GiB" , vols [0 ].ID , vols [0 ].AvailabilityZone , vols [0 ].Size )
122
- accessibleTopology := getTopology (& vols [0 ], accessibleTopologyReq , ignoreVolumeAZ )
120
+ accessibleTopology := getTopology (& vols [0 ], accessibleTopologyReq , cs . Driver . withTopology , ignoreVolumeAZ )
123
121
return getCreateVolumeResponse (& vols [0 ], nil , accessibleTopology ), nil
124
122
}
125
123
@@ -246,7 +244,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
246
244
247
245
klog .V (4 ).Infof ("CreateVolume: Successfully created volume %s in Availability Zone: %s of size %d GiB" , vol .ID , vol .AvailabilityZone , vol .Size )
248
246
249
- accessibleTopology := getTopology (vol , accessibleTopologyReq , ignoreVolumeAZ )
247
+ accessibleTopology := getTopology (vol , accessibleTopologyReq , cs . Driver . withTopology , ignoreVolumeAZ )
250
248
251
249
return getCreateVolumeResponse (vol , volCtx , accessibleTopology ), nil
252
250
}
@@ -1038,18 +1036,20 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi
1038
1036
}, nil
1039
1037
}
1040
1038
1041
- func getTopology (vol * volumes.Volume , topologyReq * csi.TopologyRequirement , ignoreVolumeAZ bool ) []* csi.Topology {
1039
+ func getTopology (vol * volumes.Volume , topologyReq * csi.TopologyRequirement , withTopology bool , ignoreVolumeAZ bool ) []* csi.Topology {
1042
1040
var accessibleTopology []* csi.Topology
1043
- if ignoreVolumeAZ {
1044
- if topologyReq != nil {
1045
- accessibleTopology = topologyReq .GetPreferred ()
1046
- }
1047
- } else {
1048
- // NOTE(stephenfin): We retrieve the AZ from the created volume rather than
1049
- // using the value we provided in our request since these can differ due to
1050
- // Cinder's '[DEFAULT] allow_availability_zone_fallback' option.
1051
- accessibleTopology = []* csi.Topology {
1052
- {Segments : map [string ]string {topologyKey : vol .AvailabilityZone }},
1041
+ if withTopology {
1042
+ if ignoreVolumeAZ {
1043
+ if topologyReq != nil {
1044
+ accessibleTopology = topologyReq .GetPreferred ()
1045
+ }
1046
+ } else {
1047
+ // NOTE(stephenfin): We retrieve the AZ from the created volume rather than
1048
+ // using the value we provided in our request since these can differ due to
1049
+ // Cinder's '[DEFAULT] allow_availability_zone_fallback' option.
1050
+ accessibleTopology = []* csi.Topology {
1051
+ {Segments : map [string ]string {topologyKey : vol .AvailabilityZone }},
1052
+ }
1053
1053
}
1054
1054
}
1055
1055
return accessibleTopology
0 commit comments