Skip to content

Commit 30277f4

Browse files
authored
Merge pull request #124 from spectrocloud/PEN-8516-Fix-Azure-Secret-Map-Contention-error
adding a lock when set up env for multiple controllers
2 parents 4aea754 + f1f1ebc commit 30277f4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

azure/scope/azure_secret_cloud.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ var (
4141
globalHTTPClient *http.Client
4242
// Mutex to protect concurrent access to global transport resources
4343
globalTransportMutex sync.RWMutex
44+
// Mutex to protect concurrent access to Azure environment map
45+
azureEnvironmentMutex sync.Mutex
4446
)
4547

4648
func init() {
@@ -131,7 +133,11 @@ func processAzureEnvironmentJSON(envJSON string) error {
131133
return errors.Wrap(err, "failed to parse Azure environment JSON")
132134
}
133135

136+
//Protect concurrent access to Azure environment map
137+
azureEnvironmentMutex.Lock()
134138
azure.SetEnvironment(env.Name, env)
139+
azureEnvironmentMutex.Unlock()
140+
135141
fmt.Printf("CAPZ: Loaded Azure environment: %s\n", env.Name)
136142
return nil
137143
}

0 commit comments

Comments
 (0)