Skip to content
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

consider: only warn on date parse error #70

Open
ekristen opened this issue Aug 22, 2024 · 2 comments
Open

consider: only warn on date parse error #70

ekristen opened this issue Aug 22, 2024 · 2 comments

Comments

@ekristen
Copy link
Owner

ekristen commented Aug 22, 2024

Original Post

In current state when you use a dateOlderThan filter, it'll return an error if it comes across a resource/field that it cannot parse as a date, and will prevent aws-nuke from running on all of the other resources it may have successfully processed

This change will instead only log a warning when an error occurs, which the user will be able to see. The resource will not be filtered out (although I'm not opinionated either way, my main goal is to not hold up aws-nuke from running because one resource was misconfigured)

I'm open to feedback/change requests

Here's an example output with these changes:

Do you really want to nuke the account with the ID 123456789012 and the alias 'my-account'?
Waiting 3s before continuing.
time="2024-07-11T21:22:47Z" level=warning msg="Failed to parse date IAMNOTADATE: unable to parse time IAMNOTADATE"
us-west-1 - DynamoDBTable - testing - [Identifier: "testing", tag:expiration-date: "IAMNOTADATE"] - would remove
Scan complete: 1 total, 1 nukeable, 0 filtered.

The above resources would be deleted with the supplied configuration. Provide --no-dry-run to actually destroy resources.

Upstream Reference: rebuy-de/aws-nuke#1245

@ekristen
Copy link
Owner Author

ekristen commented Aug 22, 2024

I think it makes sense to just change this behavior to log the error. After thinking about this this wont actually change the filtering. It wouldn't have matched to begin with and an error just interrupts.

@ekristen ekristen transferred this issue from ekristen/aws-nuke Aug 22, 2024
@ekristen
Copy link
Owner Author

I think this should remain error because this is parsing the configuration and if it's an invalid duration it should be error'd out, or we need a validation on config to error it out before this point.

https://github.com/ekristen/libnuke/blob/main/pkg/filter/filter.go#L131-L134

However, this one should just be a log message because if it gets bad data from a resource, we shouldn't full stop.

https://github.com/ekristen/libnuke/blob/main/pkg/filter/filter.go#L135-L138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant