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

New pipeline: deregister old AMIs #1414

Merged
merged 4 commits into from
Dec 17, 2024
Merged

New pipeline: deregister old AMIs #1414

merged 4 commits into from
Dec 17, 2024

Conversation

yob
Copy link
Contributor

@yob yob commented Dec 17, 2024

We've been publishing AMIs to 20 regions for ~6 years, and we've built quite a collection.

Many of them we want to keep indefinitely, like any that we've published in a released Cloud Formation template on [1]. Or any that were published in the last 12 months.

However, there's many many other images that it's safe to garbage collect. For example, we publish AMIs to every region for every main branch build, so we and customers can test them. They're useful for a short time, but any older than 12 months we can remove. By that time, customers have the option to move to a formal release with the features they want.

[1] https://github.com/buildkite/elastic-ci-stack-for-aws/releases

@yob yob force-pushed the clean-old-amis branch 2 times, most recently from 3a9f5a3 to 85d4a4e Compare December 17, 2024 13:14
We've been publishing AMIs to 20 regions for ~6 years, and we've built
quite a collection.

Many of them we want to keep indefinitely, like any that we've
published in a released Cloud Formation template on [1]. Or any that
were published in the last 12 months.

However, there's many many other images that it's safe to garbage
collect. For example, we publish AMIs to every region for every main
branch build, so we and customers can test them. They're useful for a
short time, but any older than 12 months we can remove. By that time,
customers have the option to move to a formal release with the features
they want.

[1] https://github.com/buildkite/elastic-ci-stack-for-aws/releases
Copy link
Contributor

@wolfeidau wolfeidau left a comment

Choose a reason for hiding this comment

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

👍🏻

@yob yob marked this pull request as ready for review December 17, 2024 22:21
Start very conservative while we build confidence in this process. We
can increase the cap in the future.
matrix:
- "us-east-1"
- "us-west-2"
- "ap-southeast-2"
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'll add the other 17 regions in a follow up PR

agents:
queue: "oss-deploy"
env:
DRY_RUN: true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for now, we're only dry running it. We'll build confidence the output looks like we expect, then remove this

end

one_year_ago = Time.now - (60 * 60 * 24 * 365)
deleted_counter = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

puts this at the end?

exit 1
end

MAX_DELETIONS = 10
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be an arg/env var? Wondering if this script would be useful to run in anger

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 was thinking of starting with 10, just to contain the blast radius of any early mistakes. Then increasing to something like 100 and letting it make progress via a scheduled build (daily? weekly?)

image.name.start_with?("buildkite-stack-") || # The name we used until mid 2019
image.name.start_with?("buildkite-stack-linux-") || # The name we used for linux amd64/arm64 from mid 2019
image.name.start_with?("buildkite-stack-windows-") # The name we used for windows amd64 from mid 2019
}
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 would prefer if we had a tag on the AMIs that we could use to find 100% of elastic stack images. Maybe ElasticStack: true or similar. This is a good start for now though

@yob yob merged commit a3ad9b2 into main Dec 17, 2024
1 check was pending
@yob yob deleted the clean-old-amis branch December 17, 2024 23:15
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