genevieve / leftovers

Go cli & library for cleaning up orphaned IAAS resources.
Apache License 2.0
149 stars 22 forks source link

Cleaning up resources that don't match the filter #80

Open mjj209 opened 5 years ago

mjj209 commented 5 years ago

The CF-Toolsmiths have implemented logic that cleans up GCP objects that don't match the explicit filter string. We wanted to recommend pushing this logic upstream into Leftovers. Would you consider cleaning up these GCP objects with Leftovers?

Specifically, we look for:

  1. Any Addresses attached to the network matching the filter
  2. Any routes attached to the network matching the filter
  3. Any DNS Record sets inside of the top level DNS zone matching the filter
  4. Any Firewall rules attached to the network matching the filter

Any of the 4 objects listed above could cause Leftovers to fail. We've found that it's safe to delete these objects, even if they do not match the filter string. I think for some objects, such as VMs, Leftovers will delete all VMs that are attached to the network in question, even if the VM name does not contain the filter. I'm curious if you would want to add more GCP objects to have this same behavior?

genevieve commented 5 years ago

@mjj209 That logic sounds great. I can't imagine a user passing a filter knowing it would match some network and not want to delete the things in that network. Would the team be able to make a PR with the current GCP objects they've updated to follow this logic and then we can see what other objects make sense after that?

genevieve commented 5 years ago

@nmahoney-pivotal @rowanjacobs Any thing y'all want to add?

genevieve commented 5 years ago

Hey @mjj209 @rowanjacobs! Are you still interested in merging this functionality upstream?

genevieve commented 4 years ago

Hi @mjj209.

I was reviewing the point about record sets in a dns zone. If a dns zone contains the filter, leftovers does delete the record sets inside of it.

https://github.com/genevieve/leftovers/blob/46d59f734f8af7b3ee68e71b239939a554f3bf7f/gcp/dns/managed_zone.go#L20 https://github.com/genevieve/leftovers/blob/46d59f734f8af7b3ee68e71b239939a554f3bf7f/gcp/dns/record_sets.go#L27-L52

I'm curious under what cases you've seen this cause leftovers to fail to clean up the gcp dns zone.

genevieve commented 4 years ago

Status: