@@ -346,6 +346,13 @@ func (c *Cloud) GetAzureDiskLabels(diskURI string) (map[string]string, error) {
346
346
return nil , err
347
347
}
348
348
349
+ labels := map [string ]string {
350
+ v1 .LabelZoneRegion : c .Location ,
351
+ }
352
+ // no azure credential is set, return nil
353
+ if c .DisksClient == nil {
354
+ return labels , nil
355
+ }
349
356
// Get information of the disk.
350
357
ctx , cancel := getContextWithCancel ()
351
358
defer cancel ()
@@ -358,7 +365,7 @@ func (c *Cloud) GetAzureDiskLabels(diskURI string) (map[string]string, error) {
358
365
// Check whether availability zone is specified.
359
366
if disk .Zones == nil || len (* disk .Zones ) == 0 {
360
367
klog .V (4 ).Infof ("Azure disk %q is not zoned" , diskName )
361
- return nil , nil
368
+ return labels , nil
362
369
}
363
370
364
371
zones := * disk .Zones
@@ -369,9 +376,6 @@ func (c *Cloud) GetAzureDiskLabels(diskURI string) (map[string]string, error) {
369
376
370
377
zone := c .makeZone (c .Location , zoneID )
371
378
klog .V (4 ).Infof ("Got zone %q for Azure disk %q" , zone , diskName )
372
- labels := map [string ]string {
373
- v1 .LabelZoneRegion : c .Location ,
374
- v1 .LabelZoneFailureDomain : zone ,
375
- }
379
+ labels [v1 .LabelZoneFailureDomain ] = zone
376
380
return labels , nil
377
381
}
0 commit comments