Skip to content

Commit

Permalink
Log peering wait errors, use ReadTimeout in peering Data Sources (#363)
Browse files Browse the repository at this point in the history
* Log peering wait errors

* run go generate

* Remove Default timeout

* Also apply Read timeout to aws network peering
  • Loading branch information
Joshua Timmons committed Aug 3, 2022
1 parent 136687f commit 7684238
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/data-sources/aws_network_peering.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ data "hcp_aws_network_peering" "test" {

Optional:

- `default` (String)
- `read` (String)


2 changes: 1 addition & 1 deletion docs/data-sources/azure_peering_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ data "hcp_azure_peering_connection" "test" {

Optional:

- `default` (String)
- `read` (String)
2 changes: 1 addition & 1 deletion internal/clients/peering.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func waitForPeeringToBe(ps peeringState) WaitFor {

result, err := stateChangeConfig.WaitForStateContext(ctx)
if err != nil {
return nil, fmt.Errorf("error waiting for peering connection (%s) to become '%s'", peeringID, ps.Target)
return nil, fmt.Errorf("error waiting for peering connection (%s) to become '%s': %v", peeringID, ps.Target, err)
}

return result.(*networkmodels.HashicorpCloudNetwork20200907Peering), nil
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/data_source_aws_network_peering.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceAwsNetworkPeering() *schema.Resource {
Description: "The AWS network peering data source provides information about an existing network peering between an HVN and a peer AWS VPC.",
ReadContext: dataSourceAwsNetworkPeeringRead,
Timeouts: &schema.ResourceTimeout{
Default: &peeringCreateTimeout,
Read: &peeringCreateTimeout,
},
Schema: map[string]*schema.Schema{
// Required inputs
Expand Down Expand Up @@ -114,7 +114,7 @@ func dataSourceAwsNetworkPeeringRead(ctx context.Context, d *schema.ResourceData
}

if waitForActive && peering.State != networkmodels.HashicorpCloudNetwork20200907PeeringStateACTIVE {
peering, err = clients.WaitForPeeringToBeActive(ctx, client, peering.ID, hvnID, loc, peeringCreateTimeout)
peering, err = clients.WaitForPeeringToBeActive(ctx, client, peering.ID, hvnID, loc, d.Timeout(schema.TimeoutRead))
if err != nil {
return diag.FromErr(err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/data_source_azure_peering_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceAzurePeeringConnection() *schema.Resource {
Description: "The Azure peering connection data source provides information about a peering connection between an HVN and a peer Azure VNet.",
ReadContext: dataSourceAzurePeeringConnectionRead,
Timeouts: &schema.ResourceTimeout{
Default: &peeringCreateTimeout,
Read: &peeringCreateTimeout,
},
Schema: map[string]*schema.Schema{
// Required inputs
Expand Down Expand Up @@ -129,7 +129,7 @@ func dataSourceAzurePeeringConnectionRead(ctx context.Context, d *schema.Resourc
}

if waitForActive && peering.State != networkmodels.HashicorpCloudNetwork20200907PeeringStateACTIVE {
peering, err = clients.WaitForPeeringToBeActive(ctx, client, peering.ID, hvnLink.ID, loc, peeringCreateTimeout)
peering, err = clients.WaitForPeeringToBeActive(ctx, client, peering.ID, hvnLink.ID, loc, d.Timeout(schema.TimeoutRead))
if err != nil {
return diag.FromErr(err)
}
Expand Down

0 comments on commit 7684238

Please sign in to comment.