@@ -69,11 +69,9 @@ const (
69
69
zoneTopologyKey = "failure-domain.beta.kubernetes.io/zone"
70
70
)
71
71
72
- var (
73
- supportedAccessMode = & csi.VolumeCapability_AccessMode {
74
- Mode : csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ,
75
- }
76
- )
72
+ var supportedAccessMode = & csi.VolumeCapability_AccessMode {
73
+ Mode : csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ,
74
+ }
77
75
78
76
// CreateVolume creates a new volume from the given request. The function is
79
77
// idempotent.
@@ -102,14 +100,13 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
102
100
return nil , status .Errorf (codes .OutOfRange , "invalid capacity range: %v" , err )
103
101
}
104
102
105
- var zone = d .zone
103
+ zone := d .zone
104
+ region := d .region
106
105
if req .AccessibilityRequirements != nil {
107
106
for _ , t := range req .AccessibilityRequirements .Requisite {
108
- region , ok := t .Segments [regionTopologyKey ]
107
+ regionStr , ok := t .Segments [regionTopologyKey ]
109
108
if ok {
110
- if region != d .region {
111
- return nil , status .Errorf (codes .ResourceExhausted , "volume can be only created in region: %q, got: %q" , d .region , region )
112
- }
109
+ region = regionStr
113
110
}
114
111
115
112
zoneStr , ok := t .Segments [zoneTopologyKey ]
@@ -126,7 +123,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
126
123
"storage_size_gibibytes" : size / giB ,
127
124
"method" : "create_volume" ,
128
125
"volume_capabilities" : req .VolumeCapabilities ,
129
- "region" : d . region ,
126
+ "region" : region ,
130
127
"zone" : zone ,
131
128
})
132
129
log .Info ("create volume called" )
@@ -160,7 +157,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
160
157
AccessibleTopology : []* csi.Topology {
161
158
{
162
159
Segments : map [string ]string {
163
- regionTopologyKey : d . region ,
160
+ regionTopologyKey : region ,
164
161
zoneTopologyKey : vol .ZoneId ,
165
162
},
166
163
},
@@ -197,7 +194,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
197
194
AccessibleTopology : []* csi.Topology {
198
195
{
199
196
Segments : map [string ]string {
200
- regionTopologyKey : d . region ,
197
+ regionTopologyKey : region ,
201
198
zoneTopologyKey : zone ,
202
199
},
203
200
},
0 commit comments