Prevent deadlock on azure zone fetch in presence of failure

parent 07424af1
...@@ -40,6 +40,7 @@ type instanceInfo struct { ...@@ -40,6 +40,7 @@ type instanceInfo struct {
// GetZone returns the Zone containing the current failure zone and locality region that the program is running in // GetZone returns the Zone containing the current failure zone and locality region that the program is running in
func (az *Cloud) GetZone() (cloudprovider.Zone, error) { func (az *Cloud) GetZone() (cloudprovider.Zone, error) {
faultMutex.Lock() faultMutex.Lock()
defer faultMutex.Unlock()
if faultDomain == nil { if faultDomain == nil {
var err error var err error
faultDomain, err = fetchFaultDomain() faultDomain, err = fetchFaultDomain()
...@@ -51,7 +52,6 @@ func (az *Cloud) GetZone() (cloudprovider.Zone, error) { ...@@ -51,7 +52,6 @@ func (az *Cloud) GetZone() (cloudprovider.Zone, error) {
FailureDomain: *faultDomain, FailureDomain: *faultDomain,
Region: az.Location, Region: az.Location,
} }
faultMutex.Unlock()
return zone, nil return zone, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment