Skip to content

Change rm to use find to avoid deleting cache directory during snapshot cleanup#10756

Merged
jslobodzian merged 2 commits intofasttrack/3.0from
sammeluch/snapshot-cache-clean
Oct 17, 2024
Merged

Change rm to use find to avoid deleting cache directory during snapshot cleanup#10756
jslobodzian merged 2 commits intofasttrack/3.0from
sammeluch/snapshot-cache-clean

Conversation

@sameluch
Copy link
Copy Markdown
Contributor

@sameluch sameluch commented Oct 16, 2024

Merge Checklist

All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)

  • The toolchain has been rebuilt successfully (or no changes were made to it)
  • The toolchain/worker package manifests are up-to-date
  • Any updated packages successfully build (or no packages were changed)
  • Packages depending on static components modified in this PR (Golang, *-static subpackages, etc.) have had their Release tag incremented.
  • Package tests (%check section) have been verified with RUN_CHECK=y for existing SPEC files, or added to new SPEC files
  • All package sources are available
  • cgmanifest files are up-to-date and sorted (./cgmanifest.json, ./toolkit/scripts/toolchain/cgmanifest.json, .github/workflows/cgmanifest.json)
  • LICENSE-MAP files are up-to-date (./LICENSES-AND-NOTICES/SPECS/data/licenses.json, ./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md, ./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)
  • All source files have up-to-date hashes in the *.signatures.json files
  • sudo make go-tidy-all and sudo make go-test-coverage pass
  • Documentation has been updated to match any changes to the build system
  • Ready to merge

Summary

What does the PR accomplish, why was it needed?
When using the precacher, the cache directory can be removed after creation causing a file not found, breaking the build. Rather than removing the folder, we will instead delete all of the rpms contained within.

Change Log
  • use find -exec rm to clean up cached rpms instead of rm -rf the cache folder
Does this affect the toolchain?

NO

Test Methodology
  • Pipeline build id: xxxx

@sameluch sameluch requested a review from a team as a code owner October 16, 2024 21:38
Comment thread toolkit/scripts/imggen.mk Outdated
$(STATUS_FLAGS_DIR)/imagegen_cleanup.flag: $(depend_REPO_SNAPSHOT_TIME)
@echo "REPO_SNAPSHOT_TIME has changed, sanitizing rpm cache"
rm -rf $(local_and_external_rpm_cache)
find $(local_and_external_rpm_cache) -type f -name '*.rpm' -exec rm -f {} +
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.

FYI find already has a -delete action, so you should be able to shorten this a bit. Also, just to be safe, it's good to surround paths with quotes in case there are any spaces in the path:

Suggested change
find $(local_and_external_rpm_cache) -type f -name '*.rpm' -exec rm -f {} +
find "$(local_and_external_rpm_cache)" -type f -name '*.rpm' -delete

Comment thread toolkit/scripts/pkggen.mk
$(STATUS_FLAGS_DIR)/build_packages_cache_cleanup.flag: $(depend_REPO_SNAPSHOT_TIME)
@echo "REPO_SNAPSHOT_TIME has changed, sanitizing rpm cache"
rm -rf $(remote_rpms_cache_dir)
find "$(remote_rpms_cache_dir)" -type f -name '*.rpm' -delete
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am wondering why are using the fasttrack/3.0 branch for this change instead of 3.0-dev ?
/cc @PawelWMS

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mfrw we are putting this to fasttrack since it is a bug which blocks the build (fasttrack is using the precacher which is what discovered this build break). As a result, we will put this to fasttrack to unblock then cherry pick to 3.0-dev to follow the normal fasttrack procedure.

@CBL-Mariner-Bot
Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants