Skip to content

[FEATURE REQUEST] Add a skip_cache argument to file.managed to suppress caching #64373

@nf-brentsaner

Description

@nf-brentsaner

Is your feature request related to a problem? Please describe.
I'd argue this is technically a bug, as the way file.managed uses hash comparison is kind of unexpected.

So, file.managed will always download a remote file to the cache to compare checksums.
This is very much not ideal for very large files, and the following scenario is impossible to define via file.managed:

  1. A file, foo.bar.dat, should be located at /srv/http/foo.bar.dat. This is stateful.
  2. This file should have a checksum of abc012.... This is stateful.
  3. The file exists and has that checksum. This is a state.

Being that source_hash is required for non-saltfs (salt://) files, a source is already provided (unless skip_verify is explicitly provided). However, this is not used in any way for name if it exists on the filesystem already and is instead used solely for the cache for transmit integrity validation.

The option should be present to have it available for both transmit and local validation, thus:

  • decreasing the need for unnecessary source fetches
    • and reducing state run times
  • giving the opportunity to bypass a local disk's cache directory for a destination that resides on e.g. network storage

Describe the solution you'd like
I propose a new boolean argument, skip_cache, with a default value of False or None.

IF:

  • skip_cache is provided/True, the cache will be bypassed entirely for all operations for this name/source pair (unless a salt:// source).
  • The name does not exist on the filesystem, the file will be fetched to the destination, but removed if it does not match source_hash.
  • name does exist on the filesystem but does not match source_hash, the file will be downloaded directly to name.

Describe alternatives you've considered
There are no alternatives; I am managing many multiple-gigabyte ISO files and stuck in a hellscape of an ever-growing minion cache, please help.

Additional context
N/A

Please Note

If this feature request would be considered a substantial change or addition, this should go through a SEP process here https://github.com/saltstack/salt-enhancement-proposals, instead of a feature request.

Unnecessary; this change should be completely backwards-compat with all existing usages of file.managed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Featurenew functionality including changes to functionality and code refactors, etc.Performancepending-discussionThe issue or pull request needs more discussion before it can be closed or mergedsecurityissues and PRs for the Security Working Group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions