Deleting a VPC

962 views
Skip to first unread message

ADAM SMITH

unread,
Jan 16, 2018, 4:30:28 PM1/16/18
to gce-discussion
Hi all,

I'm currently trying to delete a VPC via API, and it doesn't work. Here's the code I'm running:

op = computeClient.networks().delete(projectID, "vpc-f2a31cb3-486d-42cd-bafa-8c8726e5897f").execute();


For some reason, the gcp console is recognizing the deletion request and it keeps saying that the network has been deleted, but it's always still there. In the past, I have been able to delete VPCs but it's been hit-or-miss. Sometimes the deletion is fast, other times slow, and sometimes it won't delete at all. Is this because the API is in the alpha stage of development, or is my API call malformed? Or some other reason? Anything you can say to help would be appreciated.


Thanks,


Adam Smith

ADAM SMITH

unread,
Jan 16, 2018, 4:46:21 PM1/16/18
to gce-discussion
A quick update,

The VPC in question had an associated firewall rule. When I deleted that rule, deletion continued normally. However, when I delete via a browser, the firewall rule is destroyed alongside the vpc. So, this is most likely some type of bug.

Dinesh (Google Platform Support)

unread,
Jan 16, 2018, 10:28:40 PM1/16/18
to gce-discussion

Hello Adam,


As per the cloud documentation[1], before deleting a VPC network, you have to delete any VMs or other resources (like firewall rules) that are still using the VPC network or subnet. Can you please confirm concerned VPC does not have any such resources attached?


I tried to reproduce your issue but unable to do so as I can delete a VPC network (without any resource attached) via compute engine API[2]. I am getting 200 OK response to my delete API request. Can you please confirm what error message or code you are getting while execution?

Can you please confirm which API version you are using (v1 or beta)?



[1]: https://cloud.google.com/vpc/docs/using-vpc#deleting_a_subnet_or_vpc_network

[2]: https://cloud.google.com/compute/docs/reference/latest/networks/delete

ADAM SMITH

unread,
Jan 18, 2018, 11:23:26 AM1/18/18
to gce-discussion
Hello Dinesh,

It turns out that the VPC still had an associated firewall rule that was preventing deletion. However, If the vpc cannot be deleted because of a firewall rule, then it seems like the JSON response should indicate some kind of error and the console should not announce that the vpc deletion operation has been completed.

This is the api version I'm using:

<groupId>com.google.cloud</groupId>
            <artifactId>google-cloud</artifactId>
            <version>0.21.1-alpha</version> 

Dinesh (Google Platform Support)

unread,
Jan 18, 2018, 6:30:04 PM1/18/18
to gce-discussion

For the required (or expected) error response, you may raise a customer issue or bug on Google public issue tracker[1] platform along with relevant logs and error screenshots. Google PIT is meant for bugs, customer issue and feature requesting tracking.


[1]: https://issuetracker.google.com


Reply all
Reply to author
Forward
0 new messages