genevieve / leftovers

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

AWS EBS volumes are not filtered #87

Closed xtreme-jon-ji closed 5 years ago

xtreme-jon-ji commented 5 years ago

We're encountering an issue when using leftovers on an account that creates multiple PCF environments. When we run leftovers, we pass in a filter whose value is the environment name. We expect that only volumes that are detached and having a tag matching the environment name are deleted.

The behaviour that we are seeing is that detached volumes are deleted regardless of whether the tags match the filter. This results in the deletion of volumes belonging to other environments, if they are detached (an example would be when the volume for a bosh director is temporarily detached to re-create the vm).

Related to https://github.com/genevieve/leftovers/issues/63. The commit associated with that issue appears to add tags to the volume identifier, but checks against the filter aren't performed.

Steps to reproduce:

  1. Create EBS volume with tag:env-name:testenv1234
  2. Create EBS volume with tag env-name:donotdelete1234
  3. Run leftovers --filter=testenv1234 --dry-run

Expected: Only one resource is returned:

[EC2 Volume: vol-aaa (State:available) (env-name:testenv1234)]

Actual: Both resources (plus any other detached disks) are returned

[EC2 Volume: vol-aaa (State:available) (env-name:testenv1234)]
[EC2 Volume: vol-bbb (State:available) (env-name:donotdelete1234)]
genevieve commented 5 years ago

Awesome! Thanks Jon! I'll cut a release when it passes CI!

genevieve commented 5 years ago

Cut release v0.52.0!