Skip to content

Conversation

@mrodm
Copy link
Contributor

@mrodm mrodm commented Feb 22, 2024

This PR adds a new daily pipeline to delete all stale resources created in both AWS and GCP cloud providers.

Example build: https://buildkite.com/elastic/elastic-package/builds/2495

Currently, to confirm how it works the commands executed are just plan.
If there is any resource to be deleted, a mail notification will be sent.

To be done in following PRs:

  • Add support to clean AWS IAM roles
  • Add support to clean AWS IAM policies
  • Add support to clean AWS Redshift clusters
  • Add support to clean AWS Schedulers

Based on this example:
https://github.com/elastic/elastic-agent/blob/5e17bc222dfa1475bbdf8cade30d67a44dceb436/.buildkite/scripts/steps/gce-cleanup.sh#L15

Tasks to be done before merging:

  • Remove step from main pipeline
  • Remove debug additions from pre-command

@mrodm mrodm self-assigned this Feb 22, 2024
@mrodm mrodm marked this pull request as ready for review February 23, 2024 16:03
@mrodm mrodm requested a review from a team February 23, 2024 16:03
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

LGTM, let's see how the plan looks like.

@mrodm
Copy link
Contributor Author

mrodm commented Mar 4, 2024

/test

1 similar comment
@mrodm
Copy link
Contributor Author

mrodm commented Mar 4, 2024

/test

@mrodm
Copy link
Contributor Author

mrodm commented Mar 4, 2024

/test

# TODO: List and delete the required resources using aws cli
echo "--- Cleaning up other AWS resources older than ${DELETE_RESOURCES_BEFORE_DATE}"
echo "--- Installing awscli"
with_aws_cli

Choose a reason for hiding this comment

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

What is the deadline? So we can add support for other resources in cloud-reaper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no hard deadline for this. We were planning to merge this PR to start checking (with plan command) if there is any stale resource with the current resources supported by cloud-reaper.

We were thinking to add in following PRs, at least listing and filtering by tags for the other resources using aws CLI directly starting with redshift clusters. But, we would prefer to do so also using cloud-reaper to keep all the cleanup process using the same tool.

Should we wait for the cloud-reaper support instead for the other resources ? Or, should we add the redshift listing/filtering with aws CLI for now and some notification ? Those redshift clusters were the resources that were left in some builds @jsoriano @kpollich

Choose a reason for hiding this comment

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

If it can wait for some time, I should be able to add support for those resources.

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 should be able to add support for those resources.
Thanks @amannocci !

I think probably we could wait for some time, WDYT @jsoriano @kpollich ?

I've just created a PR to list if there is any AWS Redshift cluster stale due to CI builds. That would allow us to receive email notifications if there is any left cluster until that support is added into cloud-reaper:
#1710

Once this support is added into cloud-reaper, this logic could be moved to the cloud-reaper for sure, so the cleanup is carried out with the same tool for all resources.

In any case, this PR could be merged to start checking there is no resource like instances or queues.

Copy link
Member

Choose a reason for hiding this comment

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

I think probably we could wait for some time, WDYT @jsoriano @kpollich ?

I think we can go by now with the supported resources and add the missing ones later.

In any case, this PR could be merged to start checking there is no resource like instances or queues.

+1

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mrodm

@mrodm mrodm requested a review from jsoriano March 5, 2024 17:01
@mrodm mrodm merged commit 346081a into elastic:main Mar 6, 2024
@mrodm mrodm deleted the add_daily_cleanup_job branch March 6, 2024 09:12
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.

4 participants