-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
google_compute_network data source now fails instantly when referring to a network that is also about to be created in 5.x #16273
Comments
@gygitlab using your code above, I can't repro the issue. I do not hit the error in both v4.80.0 and v5.0.0. Can you share your debug logs for both 4.x and 5.x and detail the steps to repro? |
Huh how interesting, well like on the other issue our code is here but I'll see if I can whip up a more specific example for you later this week. |
@gygitlab I guess you have followed the v5.0.0 upgrade guide when you moved to v5.x, right? |
I did indeed as well as do a clean build with 5.0.0 yeah (well it failed instantly since the data source attempts to find the database instantly before it's created) |
@gygitlab waiting for your config and repro steps |
Ok had another go at this and indeed it's certainly a bit weird but I am able to recreate it with the following config: locals {
create_test_network = true
test_vpc_name = local.create_test_network ? google_compute_network.test_vpc[0].name : "default"
}
data "google_compute_network" "test_network" {
name = local.test_vpc_name
}
resource "google_compute_network" "test_vpc" {
count = local.create_test_network ? 1 : 0
name = "test-vpc"
auto_create_subnetworks = false
} Effectively for some reason with 5.x the Terraform behavior rules around reading data resurce are being triggered differently with the above and it's attempting to read the data during the planning phase. To put that plainly with the above config Terraform thinks While this feels like it could be a Terraform issue this exact same code passes absolutely fine with Debug outputs of |
Yeah, I can repro the issue now. Thanks @gygitlab @roaks3 I see HandleDataSourceNotFoundError was introduced in 5.x. Should it be used for this data source? |
This is working as intended -- the reason it worked before was purely because the data source in question did not return errors on 404s, which was inconsistent across the provider and was intended to function as it does now (this prior mistaken functionality giving the illusion of "waiting" the way a deferred plan does). But to elaborate why this isn't a deferred data source using the rules on the page you linked:
because of the above, (data)
no custom conditions are used in this config, and this would a potential solution to your config, updating the data source block to resemble the following
or doing some other change within your locals{} values to make Most simply being adding a |
Closed based on #16273 (comment) |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
modular-magician
user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot
, a community member has claimed the issue already.Terraform Version
v1.5.5
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
In the 4.x Terraform provider the
google_compute_network
data source would wait gracefully if it's passed a name of a network to be created.Actual Behavior
In 5.x this behaviour no longer happens and the data source immediately attempts to find the network and fails as a race condition:
Steps to Reproduce
Have a
google_compute_network
data source referring to the name parameter of agoogle_compute_network
resource (typically used in conditionals when working with multiple network types) and attempt to apply with the 4.x and 5.x GCP provider.Note this works fine with 4.x gracefully but fails immediately on 5.x
The text was updated successfully, but these errors were encountered: