Skip to content

Clean up stale buildcaches#709

Open
Sbozzolo wants to merge 2 commits intomainfrom
gbozzola/cleanup_ghcr
Open

Clean up stale buildcaches#709
Sbozzolo wants to merge 2 commits intomainfrom
gbozzola/cleanup_ghcr

Conversation

@Sbozzolo
Copy link
Copy Markdown
Member

@Sbozzolo Sbozzolo commented Apr 16, 2026

The GHCR is owned by the organization, so I needed to use crane to link the build artifacts to the repo. Then, I could delete them. Now, palace-develop-testing is linked to the repo and can be cleaned.

In this, I also fixed skipping the container workflow (because its status is required for merge)

Closes #524

@Sbozzolo Sbozzolo added ci Related to continuous integration (CI) and/or GitHub Actions spack labels Apr 16, 2026
@Sbozzolo Sbozzolo force-pushed the gbozzola/cleanup_ghcr branch 2 times, most recently from b64dfe7 to 3828528 Compare April 17, 2026 17:42
@Sbozzolo Sbozzolo force-pushed the gbozzola/cleanup_ghcr branch from 3828528 to 789f36c Compare April 17, 2026 17:44
@Sbozzolo Sbozzolo marked this pull request as ready for review April 17, 2026 17:45
Copy link
Copy Markdown
Contributor

@cameronrutherford cameronrutherford left a comment

Choose a reason for hiding this comment

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

I think the first few comments I left are just naive. I would be curious to hear if you can modify the condition for deletion slightly.

Comment thread .github/workflows/containers.yml
Comment thread .github/workflows/ghcr-cleanup.yml
Comment on lines +20 to +22
# We used `crane mutate --label` to add this to a tag in the package, which
# caused GHCR to auto-link the package to this repo. Once linked, the
# association persists at the GitHub level regardless of individual tag labels.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe I am just naive but who is "we" here? Our CI jobs do this?

# gh api orgs/awslabs/packages/container/palace-develop-testing \
# --jq '.repository.full_name'
#
# Or as a GitHub Actions step:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am interpreting this as "one needs to do this one-off operation on the index.spack in order to delete binaries in the future"?

Which begs the question - why don't we do this then in our GH Actions?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct. This is a one-off operation, but it it not cheap (if you do it naively). I thought about adding to our actions but I found that processing all the packages we have in our binary cache would take several hours.

We could do something smarter, but I figured that we won't need to do this ever again (unless we change the name of the palace-develop-testing package), so I didn't bother


on:
schedule:
- cron: '0 6,18 * * *' # Twice daily at 6:00 and 18:00 UTC
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe just once a week is fine? Curious how you decided on this cadence.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The action can only remove up to 100 packages every time it runs.

Comment on lines +62 to +64
# Each Spack spec is a tagged version in the container package. We keep
# the most recent 500 versions (roughly 5-10 full build sets) and delete
# older ones. The action deletes at most 100 per run.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would love to be a bit more scientific about this if possible.

I am reading this as it deletes anything past n=500.

That seems potentially too many deletions if we end up expanding the matrix of builds that we want to support. Ideally I would hope that one can just delete based on the age of an installation / the time since an installation was last used.

In other words, it would be ideal to cleanup based on a different criteria:

Any binary older than a week, that also hasn't been used in the last week

@Sbozzolo Sbozzolo added the no-long-tests This PR does not require the long tests to be merged label Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Related to continuous integration (CI) and/or GitHub Actions no-long-tests This PR does not require the long tests to be merged spack

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GHCR cleanup

2 participants