@@ -98,7 +98,7 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
98
98
}
99
99
100
100
// Topology overwrites Storage Class Params if specified
101
- // TODO: Support preferred toplogies .
101
+ // TODO: Support preferred topologies .
102
102
if req .GetAccessibilityRequirements () != nil {
103
103
if len (configuredZone ) != 0 {
104
104
return nil , status .Error (codes .InvalidArgument , fmt .Sprintf ("CreateVolume only one of parameter zone or topology zone may be specified" ))
@@ -369,11 +369,11 @@ func (gceCS *GCEControllerServer) ValidateVolumeCapabilities(ctx context.Context
369
369
glog .V (5 ).Infof ("Using default ValidateVolumeCapabilities" )
370
370
// Validate Arguments
371
371
if req .GetVolumeCapabilities () == nil || len (req .GetVolumeCapabilities ()) == 0 {
372
- return nil , status .Error (codes .InvalidArgument , "ControllerUnpublishVolume Volume Capabilities must be provided" )
372
+ return nil , status .Error (codes .InvalidArgument , "ValidateVolumeCapabilities Volume Capabilities must be provided" )
373
373
}
374
374
volumeID := req .GetVolumeId ()
375
375
if len (volumeID ) == 0 {
376
- return nil , status .Error (codes .InvalidArgument , "ControllerUnpublishVolume Volume ID must be provided" )
376
+ return nil , status .Error (codes .InvalidArgument , "ValidateVolumeCapabilities Volume ID must be provided" )
377
377
}
378
378
z , n , err := common .SplitZoneNameId (volumeID )
379
379
if err != nil {
@@ -403,6 +403,29 @@ func (gceCS *GCEControllerServer) ValidateVolumeCapabilities(ctx context.Context
403
403
// TODO: Ignoring mount & block types for now.
404
404
}
405
405
406
+ for _ , top := range req .GetAccessibleTopology (){
407
+ for k ,v := range top .GetSegments (){
408
+ switch k {
409
+ case common .TopologyKeyZone :
410
+ // take the zone from v and see if it matches with zone
411
+ if v == z {
412
+ // Accessible zone matches with storage zone
413
+ return & csi.ValidateVolumeCapabilitiesResponse {
414
+ Supported : true ,
415
+ }
416
+ } else {
417
+ // Accessible zone does not match
418
+ return & csi.ValidateVolumeCapabilitiesResponse {
419
+ Supported : false ,
420
+ Message : fmt .Sprintf ("Volume %s is not accesible from topology %s:%s" , volumeID , k ,v )
421
+ }
422
+ }
423
+ case default :
424
+ return nil , status .Error (codes .InvalidArgument , "ValidateVolumeCapabilities unknown topology segment key" )
425
+ }
426
+ }
427
+ }
428
+
406
429
return & csi.ValidateVolumeCapabilitiesResponse {
407
430
Supported : true ,
408
431
}, nil
@@ -501,10 +524,10 @@ func pickTopology(top *csi.TopologyRequirement) (string, error) {
501
524
reqTop := top .GetRequisite ()
502
525
prefTop := top .GetPreferred ()
503
526
504
- // Pick the preferred toplogy in order
527
+ // Pick the preferred topology in order
505
528
if len (prefTop ) != 0 {
506
529
if prefTop [0 ].GetSegments () == nil {
507
- return "" , fmt .Errorf ("preferred toplogies specified specified but no segments" )
530
+ return "" , fmt .Errorf ("preferred topologies specified but no segments" )
508
531
}
509
532
510
533
// GCE PD cloud provider Create has no restrictions so just create in top preferred zone
@@ -516,7 +539,7 @@ func pickTopology(top *csi.TopologyRequirement) (string, error) {
516
539
} else if len (reqTop ) != 0 {
517
540
r := rand .Intn (len (reqTop ))
518
541
if reqTop [r ].GetSegments () == nil {
519
- return "" , fmt .Errorf ("requisite toplogies specified specified but no segments in requisite topology %v" , r )
542
+ return "" , fmt .Errorf ("requisite topologies specified but no segments in requisite topology %v" , r )
520
543
}
521
544
522
545
zone , err := getZoneFromSegment (reqTop [r ].GetSegments ())
0 commit comments