Skip to content

Commit

Permalink
fix: refine get zone logic
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Oct 9, 2021
1 parent 52f96a2 commit 0ffe1d9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/azuredisk/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,7 @@ func (d *Driver) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabi

// NodeGetInfo return info of the node on which this plugin is running
func (d *Driver) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
var (
instanceType string
zone cloudprovider.Zone
zoneError error
)
var instanceType string
topology := &csi.Topology{
Segments: map[string]string{topologyKey: ""},
}
Expand All @@ -319,7 +315,6 @@ func (d *Driver) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (
} else {
klog.Warningf("get instance type(%s) failed with: %v", d.NodeID, err)
}
zone, zoneError = d.cloud.GetZone(ctx)
} else {
instances, ok := d.cloud.Instances()
if !ok {
Expand All @@ -329,8 +324,18 @@ func (d *Driver) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (
if instanceType, err = instances.InstanceType(ctx, types.NodeName(d.NodeID)); err != nil {
klog.Warningf("get instance type(%s) failed with: %v", d.NodeID, err)
}
}

var (
zone cloudprovider.Zone
zoneError error
)
if runtime.GOOS == "windows" && (!d.cloud.UseInstanceMetadata || d.cloud.Metadata == nil) {
zone, zoneError = d.cloud.VMSet.GetZoneByNodeName(d.NodeID)
} else {
zone, zoneError = d.cloud.GetZone(ctx)
}

if zoneError != nil {
klog.Warningf("get zone(%s) failed with: %v", d.NodeID, zoneError)
} else {
Expand Down

0 comments on commit 0ffe1d9

Please sign in to comment.