-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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_service_networking_connection destroy calls appear to always fail in 5.x despite guidance #16275
google_service_networking_connection destroy calls appear to always fail in 5.x despite guidance #16275
Comments
@gygitlab can you share your debug log? |
I did but I also reproduced the behaviour clean with an environment built from 5.x |
@gygitlab the issue looks like happening among several resources. Can you share a minimum config that I can use to repro? |
@gygitlab can you share your debug logs for apply & destroy in 4.x and 5.x? |
I've not had time to get everything but I have got a test config for you:
The key here is the updated call in 5.x is triggering what appear to be a failsafe when cloud sql is present but it doesn't appear to ever clear on GCP's end (I kept trying it for over 4 days). I suspect it never actually clears for some reason as it fails always with the error in Terraform with 5.x but I can just go to the UI and delete the service connection peering fine. I would maybe consider going back to the 4.x method for the provider at this time (or giving the option to invoke it alternatively) while figuring out what's going on on GCPs end as having terraform fail like this is not great. Debug output for both versions - https://gist.github.com/gygitlab/420a4ab2f66307cfde793b879dde0484 |
@gygitlab thanks for the info. But I noticed that in the v4.84.0 log, there are 4 resources to be deleted, while in the v5.2.0, there are only 3 resources, and the Below resource is not in the plan, To fix the problem, I guess you may want to delete the connection via other means now
|
The output was large so I tried to cut them down, let me double check.
This would be a notable impact and regression for us from the behaviour in 4.x yeah |
Ok the gist has been updated now with full destroy output for both versions thanks. |
I can repro the issue where it happens only on Comparing the processes between v4.x and v5.x, Below is the note about changes in google_service_networking_connection for v5 upgrade @roaks3 what do you think? |
Noting that I've experienced similar issues, and the blocker seems to be deleting "VPC peering" from the GCP console See the first tip in this section for the procedure we've had to follow as a workaround here: https://econia.dev/off-chain/dss/terraform#take-down-infrastructure |
I am also experiencing this issue. Cannot destroy service networking connection - after doing so manually in the gcp console, the rest destroys just fine. My current workaround is an extra CI job that runs before the destroy step to remove the VPC peering using gcloud cli. |
@MarijnMB something like this? resource "google_service_networking_connection" "sql_network_connection" {
network = google_compute_network.sql_network.id
provider = google-beta
reserved_peering_ranges = [google_compute_global_address.private_ip_address.name]
service = "servicenetworking.googleapis.com"
provisioner "local-exec" {
when = destroy
# Manually destroy VPC peering.
# This is because the dependency solver doesn't properly destroy.
# https://github.com/hashicorp/terraform-provider-google/issues/16275
command = join(" ", [
"gcloud compute networks peerings delete",
"servicenetworking-googleapis-com",
"--network sql-network",
"--quiet"
])
}
} I'm trying this out and can delete via |
@alnoki more like (.gitlab-ci.yml):
|
I'm not sure I'm following this logic sorry. In our case Terraform simply fails to destroy every time and leaves itself with a problematic partial state, which didn't happen in 4.x. Others look to be affected as well. How is this not considered a regressive issue? We're blocked on upgrading to 5.x until this is fixed. |
I was able to reproduce this issue. removePeering is not documented because the last revision switched the underlying implementation from compute api library to the service networking library. You can see remove peering is still available from the compute api: I guess for some reason it is not implemented in the service networking library. So we can either abandon terraform state or add back removePeering functionality that uses the compute api. |
Is there an update to this? We have teams using the latest version but are unable to destroy cleanly as in version 4.x. |
I am also having this issue. Here is my setup
within the network. The issue happens when I terraform delete my cloudsql and redis in seperate folders and seperate terraform state, the deletion of
as it still thinks there are services using it. I manually deleted VPC Network Peering from within the network's VPC NETWORK PEERING tab and it allowed the destruction to complete. Investigating more it seemed like some NEGs attached to one of the cluster's nodes was still around even though the cluster and its nodepools were deleted with terraform... |
Also hitting this since upgrading to version 5 of the provider. Any news on a fix? |
Workaround by using google-beta on provider version 4 and specifying the google-beta provider on the
|
The Google-internal ticket has an owner who is investigating, assigning modular-magician to mark that. |
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
Terraform 1.5.5
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
Terraform should be able to destroy it's resources gracefully and complete successfully with the 5.x provider
Actual Behavior
With the stated change from the
removePeering
todeleteConnection
method in the 5.x provider a regression arguably has occurred.The 4.x version of the provider was able to cleanly destroy the service networking connection and in turn the VPC it was attached to (if created) and ended successfully.
The switch in 5.x now prevents this with the following error:
While it's stated this may be expected as the background deletions of dependent resources such as Cloud SQL is still proceeding in practice it doesn't seem to be the case. I had created a connection a week ago and was still not able to delete it today (all other resources were deleted) but as soon as I switched over to 4.x I able to remove all resources correctly. Testing further with 5.x I was able to remove the connection manually via UI when Terraform was still posting the same error also. This suggests a bug is actually present and Terraform can no longer delete the connection at all.
With the above hard error it causes Terraform to error and leave with an impartial state leading to a worsened UX also. Terraform was not designed in mind to have resources that cannot be destroyed.
Steps to Reproduce
Attempt to destroy a
google_service_networking_connection
resource with the 5.x provider and note that it is never successful.Head to the UI instead and delete the connection under the VPC and notice it deletes successfully despite the Terraform error.
b/308248337
The text was updated successfully, but these errors were encountered: