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

update circleci config to run aws-nuke nightly #12

Merged
merged 5 commits into from
Feb 21, 2018
Merged

Conversation

tonerdo
Copy link
Contributor

@tonerdo tonerdo commented Feb 20, 2018

No description provided.

circle.yml Outdated
- test
filters:
tags:
only: /^v.*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will run aws-nuke every time we do a release. We probably only want to do it nightly, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this, left over from a copy paste

circle.yml Outdated
- checkout
- attach_workspace:
at: /go/src/github.com/gruntwork-io/aws-nuke
- run: go run main.go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this exclude us-west-2? And only delete resources older than, say, 2 days?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 2 days is fair, although I'm interested to know how you arrived at that figure because I was gonna go with 24hrs. What's the frequency at which resources are typically created in the Phx DvOps account?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 days is just a guess. We may have to tweak it later. Resources that are left from tests would ideally be cleaned up nightly. However, we also use Phx DevOps for manual testing, and occasionally, we leave things running a bit longer.

circle.yml Outdated
@@ -42,6 +42,14 @@ jobs:
root: .
paths: bin

run:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call this something more descriptive, like nuke_phx_devops.

@tonerdo
Copy link
Contributor Author

tonerdo commented Feb 20, 2018

@brikis98 the nuke_phx_devops job fails because circleci isn't equipped to provide input via stdin. I was thinking that we could add another cli flag that skips the prompt all together. @josh-padnick also thinks the same and even suggested --force. Thoughts?

circle.yml Outdated

- nuke_phx_devops:
requires:
- test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will run aws-nuke after every commit... to delete resources more than 48h old. What's the purpose of that? I don't think we need this here; we should only have the nuke_phx_devops run once nightly.

@brikis98
Copy link
Member

@brikis98 the nuke_phx_devops job fails because circleci isn't equipped to provide input via stdin. I was thinking that we could add another cli flag that skips the prompt all together. @josh-padnick also thinks the same and even suggested --force. Thoughts?

Yes, the tool definitely need a non-interactive mode. A --force flag to disable all interactive prompts sounds like a good idea.

Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there! Last couple nitpicky things to try to protect users :)

commands/cli.go Outdated
@@ -33,6 +33,10 @@ func CreateCli(version string) *cli.App {
Usage: "Only delete resources older than this specified value. Can be any valid Go duration, such as 10m or 8h.",
Value: "0s",
},
cli.BoolFlag{
Name: "force",
Usage: "Skip nuke confirmation prompt",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should put a big "WARNING: this will automatically delete all resources without any confirmation" here :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other safety measure to consider: When aws-nuke is run with --force, show the warning but sleep for, say, 5 - 10 seconds so that an interactive user has an opportunity to abort the run.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A 10 second "oh shit" pause is a very good idea. #14

commands/cli.go Outdated
}
}
} else {
if err := aws.NukeAllResources(account, regions); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a log statement here that says "The --force flag is set, so proceeding without confirmation."

Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, LGTM, thx!

@brikis98 brikis98 merged commit 01ca5be into master Feb 21, 2018
@brikis98
Copy link
Member

Make sure to delete the branch and cut a new release when you're ready.

Also, please give aws-nuke a manual run with the --older-than 48h --exclude-region us-west-2 params, as there are a bunch of resources that need clean up now.

Finally, do one more experiment: run the tests and make sure that all the resources they create are cleaned up by the tests themselves. There are a lot of aws-nuke resources in the Phx DevOps account, so I suspect some test is failing to clean up after itself. The nightly run will eventually take care of that, but only after 2 days, so it would be better if the tests did the cleanup properly and aws-nuke only picked up the slack on case of (hopefully) rare bugs/crashes/etc.

@tonerdo tonerdo deleted the nightly-run branch February 21, 2018 11:37
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

Successfully merging this pull request may close these issues.

3 participants