Skip to content

Conversation

@nawazkh
Copy link
Member

@nawazkh nawazkh commented Oct 7, 2024

What type of PR is this?
/kind cleanup

What this PR does / why we need it:

  • Cleanup GitHub action caches every Tuesday midnight

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

  • cherry-pick candidate

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 7, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign neolit123 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 7, 2024
@codecov
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.35%. Comparing base (ec7e9b0) to head (4289b5d).
Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5165   +/-   ##
=======================================
  Coverage   51.35%   51.35%           
=======================================
  Files         273      273           
  Lines       24671    24671           
=======================================
  Hits        12670    12670           
  Misses      11212    11212           
  Partials      789      789           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nawazkh
Copy link
Member Author

nawazkh commented Oct 7, 2024

Can any of the maintainers test this by manually running this workflow?
Expected output: Cleanups Actions -> Caches. We have about 13.6Gb of Caches that should get reduced.
Note that, caches older than 30 days will be deleted.

@willie-yao
Copy link
Contributor

@nawazkh I'd love to run this but I'm not sure if I can run a workflow from your fork on GitHub actions. Do you know if there's a way for me to do this?

@nawazkh
Copy link
Member Author

nawazkh commented Oct 8, 2024

@nawazkh I'd love to run this but I'm not sure if I can run a workflow from your fork on GitHub actions. Do you know if there's a way for me to do this?

You might want to run the below script from your local and see if a cache gets deleted.

export MAX_CACHE_AGE_DAYS=30
#!/bin/bash

echo "Fetching list of caches..."
# List caches

caches=$(gh actions-cache list --json id,createdAt)
echo "Caches found: $(echo "$caches" | jq '. | length')"
# Get current time
current_time=$(date +%s)
# Loop through all caches and delete those older than MAX_CACHE_AGE_DAYS
for cache_id in $(echo "$caches" | jq -r '.[] | select((('"$current_time"' - (.createdAt | fromdateiso8601 | mktime)) / 86400) > '"$MAX_CACHE_AGE_DAYS"') | .id'); do
 echo "Deleting cache with ID: $cache_id"
 gh actions-cache delete $cache_id --confirm
 echo "Deleted cache $cache_id"
 exit 0
done

^ this shell script is a copy paste from the PR but with one extra exit. Notice that I added an exit 0 to exit after one cache deletion.
I cannot run it since I do not have the permissions play with CAPZ caches.

@willie-yao
Copy link
Contributor

willie-yao commented Oct 8, 2024

I got this error when running the command:

Fetching list of caches...
Caches found: 22
jq: error (at <stdin>:1): date "2024-10-07T21:39:13.0633333Z" does not match format "%Y-%m-%dT%H:%M:%SZ"

I also had to change gh actions-cache list to gh cache list but I'm guessing that's just a local difference from running the command on gh actions.

We are removing all caches on Wednesday mid night since CAPZ dependencies get updated on Monday via Dependabot.
@nawazkh nawazkh changed the title Remove GitHub-actions caches that are older than 30 days Remove GitHub-actions caches every Tuesday midnight. Oct 8, 2024
@nawazkh nawazkh changed the title Remove GitHub-actions caches every Tuesday midnight. [WIP] Remove GitHub-actions caches every Tuesday midnight. Oct 8, 2024
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 8, 2024
@nawazkh
Copy link
Member Author

nawazkh commented Oct 8, 2024

I was looking at the cache, and noticed that the older caches(more than 22 days) get auto deleted.
We might not need this solution after all.

Thank you for checking the code nonetheless @willie-yao !

/close

@k8s-ci-robot
Copy link
Contributor

@nawazkh: Closed this PR.

In response to this:

I was looking at the cache, and noticed that the older caches(more than 22 days) get auto deleted.
We might not need this solution after all.

Thank you for checking the code nonetheless @willie-yao !

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@nawazkh nawazkh deleted the clear_old_cache branch October 8, 2024 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants