Skip to content

Conversation

@ebtasam-faridy
Copy link

@ebtasam-faridy ebtasam-faridy commented Aug 29, 2025

Jira: https://harness.atlassian.net/browse/CI-18276?focusedCommentId=1217420

This PR addresses a critical issue where the Harness CI cache plugin fails to preserve file timestamps when restoring caches from S3 or GCS. This bug prevents time-based cleanup mechanisms, like Gradle's built-in pruning and standard find commands, from correctly identifying and deleting old cache files.

The fix introduces a new, optional boolean flag, preserve_metadata, which defaults to false for backward compatibility. When set to true, the plugin will now explicitly restore the original file timestamps upon extracting the cache to the build agent.

Key changes:

New Flag: preserve_metadata is added to the plugin settings.

Core Logic: The plugin will now restore file timestamps to their original values.

Scope: This fix applies to the S3 and GCS backends of the drone-cache plugin.

Acceptance Criteria: After this change, time-based cache cleanup will function correctly, ensuring that old files are properly removed to save disk space.

This enhancement is crucial for ensuring the efficiency and health of build agent disk space over time.

Executions:
S3
linux k8s: https://qa.harness.io/ng/account/h61p38AZSV6MzEkpWWBtew/all/orgs/default/projects/V[…]pUPZp3rkw&step=whCLcek2SMuCX3MqLgcWLQ&childStage=&stageExecId=
linux amd64 hosted:
https://qa.harness.io/ng/account/h61p38AZSV6MzEkpWWBtew/all/orgs/default/projects/V[…]1MDTygs4g&step=dfb1JTzcTHqCXcNAG8K54w&childStage=&stageExecId=
linux arm64 hosted:
https://qa.harness.io/ng/account/h61p38AZSV6MzEkpWWBtew/all/orgs/default/projects/V[…]iIGiPhZTA&step=VwLtHBo2SoiIMabgltI0IA&childStage=&stageExecId=
windows amd64 hosted:
https://qa.harness.io/ng/account/h61p38AZSV6MzEkpWWBtew/all/orgs/default/projects/V[…]Y6rC-JcSg&step=GWAuWMkVRlWi25QNkoLNEA&childStage=&stageExecId=
GCS
linux amd k8:
https://qa.harness.io/ng/account/h61p38AZSV6MzEkpWWBtew/all/orgs/default/projects/V[…]s/HIB37_VXQxuqu32T1KN02w/pipeline?stage=fxJ4nGhOSVGR7AwmVhXyBw
linux amd64 hosted:
https://qa.harness.io/ng/account/h61p38AZSV6MzEkpWWBtew/all/orgs/default/projects/V[…]s/QQDhNZTgRoCu8J1vvi2Hpw/pipeline?stage=joHCSxrDRseWKIRWS6HfEQ
linux arm64 hosted:
https://qa.harness.io/ng/account/h61p38AZSV6MzEkpWWBtew/all/orgs/default/projects/V[…]s/Leng1b3WRBCxt7KpinNqaA/pipeline?stage=bBDq1S5AQDeQchI0YzL67A
windows amd64 hosted:
https://qa.harness.io/ng/account/h61p38AZSV6MzEkpWWBtew/all/orgs/default/projects/V[…]s/C8scgYOESyCAUJF6xdYXNQ/pipeline?stage=SVHJ1EBiQj2uq1rscpvirw
disabled:
https://qa.harness.io/ng/account/h61p38AZSV6MzEkpWWBtew/all/orgs/default/projects/V[…]ed/executions/jiTjxCsLS9C_ZOJhCgeakA/pipeline?storeType=INLINE

Final execution with deletion logic:
https://qa.harness.io/ng/account/h61p38AZSV6MzEkpWWBtew/all/orgs/default/projects/Vikas/pipelines/GCS_Test_Hosted/executions/6RTWbmiSQyiUnYV71rS2gg/pipeline

without the flag: https://qa.harness.io/ng/account/h61p38AZSV6MzEkpWWBtew/all/orgs/default/projects/Vikas/pipelines/GCS_Test_Hosted/executions/TAu-LxlfRK-UYznsAcCHaQ/pipeline

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Fixes #

Proposed Changes

Description

Checklist

  • Read the CONTRIBUTING document.
  • Read the CODE OF CONDUCT document.
  • Add tests to cover changes.
  • Ensure your code follows the code style of this project.
  • Ensure CI and all other PR checks are green OR
    • Code compiles correctly.
    • Created tests which fail without the change (if possible).
    • All new and existing tests passed.
  • Add your changes to Unreleased section of CHANGELOG.
  • Improve and update the README (if necessary).
  • Ensure documentation is up-to-date. The same file will be updated in plugin index when your PR is accepted, so it will be available for end-users at http://plugins.drone.io.

@ebtasam-faridy
Copy link
Author

@Sapa96 can you please review

@Ompragash Ompragash merged commit b0dd248 into drone-plugins:master Sep 8, 2025
7 checks passed
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.

3 participants