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

feat(ci): delete unused artifacts in registries #5873

Merged
merged 5 commits into from
Jan 16, 2023
Merged

Conversation

gustavovalverde
Copy link
Member

@gustavovalverde gustavovalverde commented Dec 19, 2022

Previous behavior:

Docker artifacts are costing us a good part of our infrastructure budget, and we needed a way to remove unused artifacts.

Expected behavior:

Delete unused (not just old) docker artifacts in GAR (Google Artifact Registry), preferably using a generic solution is this needs to be expanded into other Docker registries.

Solution:

Implement GCR Cleaner https://github.com/GoogleCloudPlatform/gcr-cleaner, as this tools provided integration with docker/login-action to interact with multiple Docker v2 registries.

Fixes #5750

Review

Anyone can review, just have to wait for manual execution to validate it's working

Reviewer Checklist

  • Will the PR name make sense to users?
    • Does it need extra CHANGELOG info? (new features, breaking changes, large changes)
  • Are the PR labels correct?
  • Does the code do what the ticket and PR says?
    • Does it change concurrent code, unsafe code, or consensus rules?
  • How do you know it works? Does it have tests?

Previous behavior:
Docker artifacts are costing us a good part of our infrastructure budget,
and we needed a way to remove unused artifacts.

Expected behavior:
Delete unused (not just old) docker artifacts in GAR (Google Artifact Registry),
preferably using a generic solution is this needs to be expanded into other
Docker registries.

Solution:
Implement GCR Cleaner https://github.com/GoogleCloudPlatform/gcr-cleaner,
as this tools provided integration with `docker/login-action` to interact
with multiple Docker v2 registries.
@gustavovalverde gustavovalverde added A-infrastructure Area: Infrastructure changes A-devops Area: Pipelines, CI/CD and Dockerfiles C-cleanup Category: This is a cleanup P-Medium ⚡ I-cost Zebra infrastructure costs C-feature Category: New features labels Dec 19, 2022
@gustavovalverde gustavovalverde self-assigned this Dec 19, 2022
@github-actions github-actions bot added the C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG label Dec 19, 2022
@gustavovalverde
Copy link
Member Author

@arya2
Copy link
Contributor

arya2 commented Dec 19, 2022

Test run available here: https://github.com/ZcashFoundation/zebra/actions/runs/3732040969/jobs/6330968018

Some of the deletions failed:

https://github.com/ZcashFoundation/zebra/actions/runs/3732040969/jobs/6330968018#step:6:183

@gustavovalverde
Copy link
Member Author

This is happening even when trying to do it manually on those digests, I'm trying to find the root-cause.

teor2345
teor2345 previously approved these changes Jan 4, 2023
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for this!

This is happening even when trying to do it manually on those digests, I'm trying to find the root-cause.

I think it's ok for us to delete most of the outdated images, and ignore any errors for now. Then if we end up with a lot of images we can't delete, we can investigate further.

(And sometimes the deletes will work the second time, because we've deleted the images that were depending on those images.)

.github/workflows/delete-gcp-resources.yml Outdated Show resolved Hide resolved
@gustavovalverde gustavovalverde marked this pull request as ready for review January 10, 2023 13:17
@gustavovalverde gustavovalverde requested a review from a team as a code owner January 10, 2023 13:17
@gustavovalverde gustavovalverde requested review from dconnolly and removed request for a team January 10, 2023 13:17
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Looks good!

I ran the workflow manually and it returned an error:

us-docker.pkg.dev/zealous-zebra/zebra/zebrad-test
2 errors occurred:
✗ no refs were deleted

https://github.com/ZcashFoundation/zebra/actions/runs/3888376395/jobs/6635625756#step:6:24

Can we set continue-on-error on the gcr-cleaner-cli step, until we fix these errors?
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error

@teor2345 teor2345 marked this pull request as ready for review January 12, 2023 07:14
@gustavovalverde
Copy link
Member Author

I ran the action manually, and it's working.

@teor2345
Copy link
Contributor

I ran the action manually, and it's working.

It looks like you ran the main branch action without these changes:
https://github.com/ZcashFoundation/zebra/actions/runs/3930069728

Here it is with the changes in this PR:
https://github.com/ZcashFoundation/zebra/actions/runs/3933727937

Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Looks good to me, fixing the typo is optional.

mergify bot added a commit that referenced this pull request Jan 16, 2023
mergify bot added a commit that referenced this pull request Jan 16, 2023
@mergify mergify bot merged commit e21d8f9 into main Jan 16, 2023
@mergify mergify bot deleted the delete-gar-images branch January 16, 2023 23:38
mergify bot added a commit that referenced this pull request Jan 16, 2023
@oxarbitrage oxarbitrage mentioned this pull request Jan 29, 2023
36 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-devops Area: Pipelines, CI/CD and Dockerfiles A-infrastructure Area: Infrastructure changes C-cleanup Category: This is a cleanup C-feature Category: New features C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG I-cost Zebra infrastructure costs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically delete old GCP Artifact Registry Storage test images
3 participants