Skip to content

Commit

Permalink
Inspec storage (#5347)
Browse files Browse the repository at this point in the history
* Use more markdown for Bug

* Consistently use sentences for each bullet

* Rewrite bug reproduction block

* Allow domain mapping to succeed if DNS is pending

Signed-off-by: Modular Magician <[email protected]>

* Updated google_folder.html (#4149)

* Updated google_folder.html

The page in the first example shows that you should use organization_id with value of 1234567. In the Import example, it's not clear whether organization_id is user, or folder_id is used. API call behind this import command is only accepting folder_id (can be checked when setting TF_LOG to trace and viewing the API call)

* Update website/docs/r/google_folder.html.markdown

Co-Authored-By: Dana Hoffman <[email protected]>

Co-authored-by: Dana Hoffman <[email protected]>

* add google_kms_secret_ciphertext resource, deprecate datasource (#5314)

Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: Dana Hoffman <[email protected]>

* Allow add/removing Bigtable clusters (#5318)

Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: Riley Karson <[email protected]>

* Add bootstrapped test networks for service networking tests (#5316)

Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: emily <[email protected]>

* Update CHANGELOG.md

* fix docs for google_bigquery_default_service_account (#5329)

Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: Martin Nowak <[email protected]>

* Nil return for absent Bigtable resources (#5331)

Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: Brian Hildebrandt <[email protected]>

* add lifecycle_config to dataproc_cluster.cluster_config

Signed-off-by: Modular Magician <[email protected]>

* Add warnings about custom role format for IAM bindings (#5335)

Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: emily <[email protected]>

* Add mutex to peering create (#5338)

Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: emily <[email protected]>

* Inspec storage (#2932)

Merged PR #2932.

Co-authored-by: Josh Soref <[email protected]>
Co-authored-by: Chris Stephens <[email protected]>
Co-authored-by: Petar Marinkovic <[email protected]>
Co-authored-by: Dana Hoffman <[email protected]>
Co-authored-by: megan07 <[email protected]>
Co-authored-by: Riley Karson <[email protected]>
Co-authored-by: emily <[email protected]>
Co-authored-by: Paddy <[email protected]>
Co-authored-by: Martin Nowak <[email protected]>
Co-authored-by: Brian Hildebrandt <[email protected]>
  • Loading branch information
11 people authored Jan 8, 2020
1 parent e10d99f commit afbc4bb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .changelog/2932.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:REPLACEME

```
33 changes: 25 additions & 8 deletions google/resource_compute_network_peering.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,22 @@ func resourceComputeNetworkPeeringCreate(d *schema.ResourceData, meta interface{
if err != nil {
return err
}
peerNetworkFieldValue, err := ParseNetworkFieldValue(d.Get("peer_network").(string), d, config)
if err != nil {
return err
}

request := &computeBeta.NetworksAddPeeringRequest{}
request.NetworkPeering = expandNetworkPeering(d)

// Only one peering operation at a time can be performed for a given network.
// Lock on both networks, sorted so we don't deadlock for A <--> B peering pairs.
peeringLockNames := sortedNetworkPeeringMutexKeys(networkFieldValue, peerNetworkFieldValue)
for _, kn := range peeringLockNames {
mutexKV.Lock(kn)
defer mutexKV.Unlock(kn)
}

addOp, err := config.clientComputeBeta.Networks.AddPeering(networkFieldValue.Project, networkFieldValue.Name, request).Do()
if err != nil {
return fmt.Errorf("Error adding network peering: %s", err)
Expand Down Expand Up @@ -139,10 +151,13 @@ func resourceComputeNetworkPeeringDelete(d *schema.ResourceData, meta interface{
Name: name,
}

// Only one delete peering operation at a time can be performed inside any peered VPCs.
peeringLockName := getNetworkPeeringLockName(networkFieldValue.Name, peerNetworkFieldValue.Name)
mutexKV.Lock(peeringLockName)
defer mutexKV.Unlock(peeringLockName)
// Only one peering operation at a time can be performed for a given network.
// Lock on both networks, sorted so we don't deadlock for A <--> B peering pairs.
peeringLockNames := sortedNetworkPeeringMutexKeys(networkFieldValue, peerNetworkFieldValue)
for _, kn := range peeringLockNames {
mutexKV.Lock(kn)
defer mutexKV.Unlock(kn)
}

removeOp, err := config.clientCompute.Networks.RemovePeering(networkFieldValue.Project, networkFieldValue.Name, request).Do()
if err != nil {
Expand Down Expand Up @@ -177,13 +192,15 @@ func expandNetworkPeering(d *schema.ResourceData) *computeBeta.NetworkPeering {
}
}

func getNetworkPeeringLockName(networkName, peerNetworkName string) string {
func sortedNetworkPeeringMutexKeys(networkName, peerNetworkName *GlobalFieldValue) []string {
// Whether you delete the peering from network A to B or the one from B to A, they
// cannot happen at the same time.
networks := []string{networkName, peerNetworkName}
networks := []string{
fmt.Sprintf("%s/peerings", networkName.RelativeLink()),
fmt.Sprintf("%s/peerings", peerNetworkName.RelativeLink()),
}
sort.Strings(networks)

return fmt.Sprintf("network_peering/%s/%s", networks[0], networks[1])
return networks
}

func resourceComputeNetworkPeeringImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
Expand Down

0 comments on commit afbc4bb

Please sign in to comment.