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

Timeouts are not applied to a Data Source read during apply #1038

Open
crhino opened this issue Aug 22, 2022 · 3 comments
Open

Timeouts are not applied to a Data Source read during apply #1038

crhino opened this issue Aug 22, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@crhino
Copy link

crhino commented Aug 22, 2022

SDK version

github.com/hashicorp/terraform-plugin-sdk/v2 v2.21.0

Relevant provider source code

func dataSourceAzurePeeringConnection() *schema.Resource {
	return &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{
			Read: 35 * time.Minute,
		},
...

Github link

Terraform Configuration Files

data "hcp_azure_peering_connection" "peering" {
  hvn_link              = var.hvn.self_link
  peering_id            = hcp_azure_peering_connection.peering.peering_id
  wait_for_active_state = true
  timeouts {
    read = "1m"
  }
}

Debug Output

Expected Behavior

I expect that the Read timeout value is correctly applied to the data source read (35 minutes in the Go code, 1 minute in the HCL example).

Actual Behavior

For all data source reads, the default 20 minutes timeout appears to be applied.

Steps to Reproduce

References

I attempted to dig a bit into the SDK code, and found the ReadDataApply function, which does not set the data.timeouts field before calling read(), unlike similar functions such as RefreshWithoutUpgrade.

If I am reading that correctly, then we are not correctly sourcing the timeouts set on the Resource.Timeouts field into the ResourceData struct?

@bcmdarroch
Copy link

Thanks for investigating this! We'll work with the plugin team to get that upstream fix.

@bflad
Copy link
Member

bflad commented Aug 29, 2022

Hi @crhino 👋 Thank you for raising this and sorry you ran into trouble here.

While we can likely bake in data source support for the timeouts mechanism at some point, I did want to mention one workaround here that can be applied today, where the data source is setup to use ReadWithoutTimeout instead of ReadContext.

For example:

func dataSourceAzurePeeringConnection() *schema.Resource {
	return &schema.Resource{
		Description: "The Azure peering connection data source provides information about a peering connection between an HVN and a peer Azure VNet.",
		ReadWithoutTimeout: dataSourceAzurePeeringConnectionRead,

This will remove the automatic 20 minute timeout that the SDK is applying to the operation. You can of course still setup your own 35 minute timeout within the read logic, if necessary.

@insanejasper
Copy link

We just released a new version of the HCP Terraform Provider which includes the workaround mentioned: https://github.com/hashicorp/terraform-provider-hcp/releases/tag/v0.44.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants