Skip to content

Commit

Permalink
Add mutex to compute_project_metadata_item (#4778)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Tomlinson <chris.tomlinson@dunnhumby.com>
  • Loading branch information
ct-dh and Chris Tomlinson authored May 17, 2021
1 parent 4cc73d1 commit 999bcfa
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ func resourceComputeProjectMetadataItemDelete(d *schema.ResourceData, meta inter

func updateComputeCommonInstanceMetadata(config *Config, projectID, key, userAgent string, afterVal *string, timeout time.Duration, failIfPresent metadataPresentBehavior) error {
updateMD := func() error {
lockName := fmt.Sprintf("projects/%s/commoninstancemetadata", projectID)
mutexKV.Lock(lockName)
defer mutexKV.Unlock(lockName)

log.Printf("[DEBUG] Loading project metadata: %s", projectID)
project, err := config.NewComputeClient(userAgent).Projects.Get(projectID).Do()
if err != nil {
Expand Down

0 comments on commit 999bcfa

Please sign in to comment.