genevieve / leftovers

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

slice bounds out of range issue when multiple instances of leftovers are deleting IAM service accounts #73

Closed weresch closed 5 years ago

weresch commented 5 years ago

Ran into an interesting scenario when we were deleting an environment on GCP with leftovers v0.45.0 and at the same time another environment was being deleted by leftovers on another machine. Our local leftovers crashed with panic: runtime error: slice bounds out of range. It looks like an array of bindings changed while we were using it:

[IAM Service Account: ] Deleting...

panic: runtime error: slice bounds out of range goroutine 457 [running]: github.com/genevieve/leftovers/gcp/iam.ServiceAccount.removeBindings(0x29827c0, 0xc0003281e0, 0x448dd60, 0xc000080880, 0xc000518000, 0x7a, 0xc0003300f0, 0x46, 0x9e, 0x280a708) /go/src/github.com/genevieve/leftovers/gcp/iam/service_account.go:76 +0xa9d github.com/genevieve/leftovers/gcp/iam.ServiceAccount.Delete(0x29827c0, 0xc0003281e0, 0x448dd60, 0xc000080880, 0xc000518000, 0x7a, 0xc0003300f0, 0x46, 0x2249e60, 0xc0001e9130) /go/src/github.com/genevieve/leftovers/gcp/iam/service_account.go:25 +0x59 github.com/genevieve/leftovers/app.AsyncDeleter.Run.func1(0xc000469400, 0x448dd40, 0xc000080880, 0xc0005321b0, 0x2981640, 0xc00039e980) /go/src/github.com/genevieve/leftovers/app/async_deleter.go:42 +0x1b6 created by github.com/genevieve/leftovers/app.AsyncDeleter.Run /go/src/github.com/genevieve/gleftovers/app/async_deleter.go:37 +0x126

genevieve commented 5 years ago

This was actually a much bigger issue than another leftovers running! Thank you for opening this. Added a test case that reproduced the issue and was able to fix the loop.

Thank you @weresch @deniseyu. This will be out in the next release!