Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log peering wait errors, use ReadTimeout in peering Data Sources #363

Merged
merged 4 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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