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

Remove case sensitivity of Etag header for use_etag #61441

Merged
merged 2 commits into from
Jan 20, 2022

Conversation

nicholasmhughes
Copy link
Collaborator

What does this PR do?

See issue.

What issues does this PR fix or reference?

Fixes: #61440

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@nicholasmhughes nicholasmhughes requested a review from a team as a code owner January 11, 2022 01:29
@nicholasmhughes nicholasmhughes requested review from waynew and removed request for a team January 11, 2022 01:29
@nicholasmhughes
Copy link
Collaborator Author

re-run full all

Copy link
Contributor

@waynew waynew left a comment

Choose a reason for hiding this comment

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

👍

tests/pytests/functional/states/test_file.py Show resolved Hide resolved
@waynew
Copy link
Contributor

waynew commented Jan 11, 2022

re-run all

@damon-atkins
Copy link
Contributor

damon-atkins commented Jan 12, 2022

Hi @nicholasmhughes thanks for doing this. A better method would be to write the whole header to a different file instead of using a file specific for etag. There are many ways to determine if a file should be cached from a web server. Keeping the whole header in a filename.meta file allows not only etag to be used but other techniques, like if-not-modified-since using the date from save header which is in the same format as what the web server provided (instead of try to create it). Instead of use_etag just have http_cache. e.g.

Here is some sample code, loading meta data, back into a case insensitive data structure.

meta_file = '{0}.meta'.format(dest_file)
with salt.utils.files.fopen(meta_file, 'r', encoding='utf-8') as meta_fh:
   cache_headers = requests.structures.CaseInsensitiveDict(data=salt.utils.json.load(meta_fh))

Not sure why salt does not use the request library.

How are you handling failures/partial downloads?

@dwoz dwoz added the Phosphorus v3005.0 Release code name and version label Jan 20, 2022
@Ch3LL Ch3LL merged commit 3292ee9 into saltstack:master Jan 20, 2022
@nicholasmhughes nicholasmhughes deleted the fix-etag-case-sensitivity branch January 20, 2022 18:27
@nicholasmhughes
Copy link
Collaborator Author

@damon-atkins , totally understand the broader metadata perspective. However, I'm not really in a spot to address that at this time.

Regarding handling failures/partial downloads, the code additions for use_etag aren't in the critical path for content download handling itself... just the decision on whether or not to download. If an etag file isn't there, is corrupted, or otherwise "partial", then it'll be treated as not matching and re-download the content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Phosphorus v3005.0 Release code name and version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] use_etag expects case-sensitive header Etag
7 participants