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

Cache package release for compression change in windows with symlink fix #1291

Merged

Conversation

Phantsure
Copy link
Contributor

@Phantsure Phantsure commented Dec 29, 2022

  • Adding changes related to compression and cross os functionality back on windows.
  • Adding symlink fix for Linux cache to restore on windows. Check Actions/cache breaks symlink on Windows runners cache#1010 for more details regarding issue.
  • Making cross-os functionality as opt-in instead of default

Please check commits after first commit to understand the changes done
Original PR: #1281

@Phantsure Phantsure changed the base branch from main to releases/cache-v3-beta December 29, 2022 11:18
@Phantsure Phantsure changed the base branch from releases/cache-v3-beta to main December 29, 2022 11:19
@Phantsure Phantsure changed the base branch from main to releases/cache-v3-beta December 29, 2022 11:25
@Phantsure Phantsure changed the base branch from releases/cache-v3-beta to main December 29, 2022 11:25
@Phantsure Phantsure marked this pull request as ready for review December 29, 2022 12:42
@Phantsure Phantsure requested review from a team as code owners December 29, 2022 12:42
@Phantsure Phantsure requested a review from lvpx December 29, 2022 12:42
@Phantsure Phantsure force-pushed the revert-1289-revert-1281-phantsure/compression-changes-release branch from 208618d to da162e4 Compare December 29, 2022 12:45
Comment on lines 81 to 83
!compressionMethod || compressionMethod === CompressionMethod.Gzip
? []
: [compressionMethod]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove this as we are not doing any special casing for gzip?

Copy link
Contributor

Choose a reason for hiding this comment

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

It will cause cache invalidation, but that will get masked by invalidation due to windows-only

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is there so that cache created by gzip is only restorable by gzip. If self-hosted runners don't have zstd then it falls back to gzip.
We can remove this if we callout that having zstd in path is a requirement for cache to work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then in that case we can remove gzip from our code. And that seems like a big change

Copy link
Contributor

Choose a reason for hiding this comment

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

Won't the fallback logic take care of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bishal-pdMSFT Yes, but you were asking if we should remove it. Right? We need to keep some component of compression algo in version

Copy link
Contributor

Choose a reason for hiding this comment

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

So just to understand, if we remove this statement, cache invalidation will happen because the newer versions will include gzip in their version hash and that won't match for older gzip caches. So even in this case, shouldn't gzip caches only be restorable by using gzip. Previously they were identified by not having gzip in version but moving forward will have gzip in version. I think this is what @bishal-pdMSFT is referring to.

Copy link
Contributor

Choose a reason for hiding this comment

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

Previously they were identified by not having gzip in version but moving forward will have gzip in version.

Yes, this is what I meant. We need not put empty compression method here for gzip and let it be handled just like any other compression method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously they were identified by not having gzip in version but moving forward will have gzip in version.

Then we can do that. Remove empty compression case here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Empty string still remains if no compression method is passed. Removed gzip case. This was present since initial commit. Let me check if it is really needed

Copy link
Contributor

@lvpx lvpx left a comment

Choose a reason for hiding this comment

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

Added comments

packages/cache/src/internal/cacheHttpClient.ts Outdated Show resolved Hide resolved
packages/cache/src/internal/cacheHttpClient.ts Outdated Show resolved Hide resolved
Comment on lines 81 to 83
!compressionMethod || compressionMethod === CompressionMethod.Gzip
? []
: [compressionMethod]
Copy link
Contributor

Choose a reason for hiding this comment

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

So just to understand, if we remove this statement, cache invalidation will happen because the newer versions will include gzip in their version hash and that won't match for older gzip caches. So even in this case, shouldn't gzip caches only be restorable by using gzip. Previously they were identified by not having gzip in version but moving forward will have gzip in version. I think this is what @bishal-pdMSFT is referring to.

Copy link
Contributor

@lvpx lvpx left a comment

Choose a reason for hiding this comment

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

Minor comments

packages/cache/src/internal/cacheHttpClient.ts Outdated Show resolved Hide resolved
packages/cache/src/internal/cacheHttpClient.ts Outdated Show resolved Hide resolved
@lvpx lvpx self-requested a review January 3, 2023 11:51
Copy link
Contributor

@lvpx lvpx left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@Phantsure Phantsure merged commit b2d865f into main Jan 4, 2023

const IS_WINDOWS = process.platform === 'win32'
exportVariable('MSYS', 'winsymlinks:nativestrict')
Copy link

Choose a reason for hiding this comment

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

This is a grave mistake. This code is supposed to be a library and not leave any remnants in the environment after it ran.

This can cause failures in GitHub workflow runs (and indeed, it did over here). You basically changed the behavior of every workflow run that involves MSYS2 (or for that matter, Git for Windows).

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @dscho, I hope this was addressed in this PR?

Copy link

Choose a reason for hiding this comment

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

That looks like it would address the issue, if in any release. I was pretty certain that I was at the current @actions/cache version when I raised the concern, though, so I am fairly confident that no released version fixes this? Am I wrong?

Copy link
Contributor

Choose a reason for hiding this comment

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

You are correct. We were in the process of getting it merged, will be creating a release to get it live.

Copy link

Choose a reason for hiding this comment

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

Thank you.

// Add compression method to cache version to restore
// compressed cache as per compression method
if (compressionMethod) {
components.push(compressionMethod)
Copy link

Choose a reason for hiding this comment

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

This is a bug, it mutates the user-provided argument paths, fix in #1378

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.

None yet

5 participants