salt icon indicating copy to clipboard operation
salt copied to clipboard

[3007.x] Don't unnecessarily download remote sources to cache

Open lkubb opened this issue 2 years ago • 1 comments

What does this PR do?

Makes file.managed check if an existing file's contents match the expected ones early (for remote sources with known source_hash). If they do, forces replace to false and thus skips fetching the file to cache.

What issues does this PR fix or reference?

Fixes: https://github.com/saltstack/salt/issues/66342 Ref: https://github.com/saltstack/salt/issues/64373

Previous Behavior

Essentially manages both intended file and file in cache, wastes resources.

New Behavior

Only manages intended file.

Merge requirements satisfied?

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

  • [x] Docs
  • [x] Changelog - https://docs.saltproject.io/en/master/topics/development/changelog.html
  • [x] Tests written/updated

Commits signed with GPG?

Yes

lkubb avatar Apr 10 '24 16:04 lkubb

@dwoz Yes, it has been this way since Salt's inception I think.

I opted to submit this for 3007 since it would require some attention if it was merged forward instead (in regards to file signature verification: it would silently forget about signature verification on the source_hash file). A backport should work fine if one just removes the new parameters from the call to file.get_source_sum.

lkubb avatar Apr 18 '24 22:04 lkubb

@lkubb Can you please backport this too?

dwoz avatar May 13 '24 21:05 dwoz

@dwoz Sure. :)

lkubb avatar May 13 '24 21:05 lkubb