You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Using file.managed with a remote source (e.g. https://) usually requires specifying a source_hash in some way. I would expect it to be used to check if an existing file's contents need to change, which is not the case. Instead, Salt uses this source hash to check if a file downloaded to cache is corrupt only, calculates its source hash and compares it to the existing file.
This behavior wastes a lot of resources (CPU cycles, disk space, bandwidth) both locally and on the remote and is completely unnecessary if we already had what we wanted before starting all this work. We're not trying to verify remote sources or manage the cache after all.
$ echo"Am I not good enough for you?"> testfile
$ sha256sum testfileb099df4a11f400546110027ffd2a5af88dd541ad353c9a0ebdc95f28ee8430cb testfile
$ salt-call state.single file.managed $(pwd)/testfile source=https://127.0.0.1:1337/nonexistent source_hash=b099df4a11f400546110027ffd2a5af88dd541ad353c9a0ebdc95f28ee8430cb[ERROR ] Failed to cache https://127.0.0.1:1337/nonexistent: Error: [Errno 111] Connection refused reading /nonexistentlocal:---------- ID: /tmp/testfile Function: file.managed Result: False Comment: Failed to cache https://127.0.0.1:1337/nonexistent: Error: [Errno 111] Connection refused reading /nonexistent Started: 17:42:21.671160 Duration: 14.082 ms Changes:
Expected behavior
local:---------- ID: /tmp/testfile Function: file.managed Result: True Comment: File /tmp/testfile is in the correct state Started: 17:45:10.117584 Duration: 7.519 ms Changes:Summary for local------------Succeeded: 1Failed: 0------------Total states run: 1Total run time: 7.519 ms
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
Salt: 3006.7Python Version:
Python: 3.10.13 (main, Feb 19 2024, 03:31:20) [GCC 11.2.0]Dependency Versions:
cffi: 1.14.6cherrypy: unknowndateutil: 2.8.1docker-py: Not Installedgitdb: 4.0.11gitpython: 3.1.42Jinja2: 3.1.3libgit2: Not Installedlooseversion: 1.0.2M2Crypto: Not InstalledMako: Not Installedmsgpack: 1.0.2msgpack-pure: Not Installedmysql-python: Not Installedpackaging: 22.0pycparser: 2.21pycrypto: Not Installedpycryptodome: 3.19.1pygit2: Not Installedpython-gnupg: 0.4.8PyYAML: 6.0.1PyZMQ: 23.2.0relenv: 0.15.1smmap: 5.0.1timelib: 0.2.4Tornado: 4.5.3ZMQ: 4.3.4System Versions:
dist: rocky 9.3 Blue Onyxlocale: utf-8machine: x86_64release: 5.14.0-362.13.1.el9_3.x86_64system: Linuxversion: Rocky Linux 9.3 Blue Onyx
Additional context
PR incoming
The text was updated successfully, but these errors were encountered:
I do have a state which bootstraps freebsd and was wondering why it takes so long on each run. I thought it was my bad and gave up. thank you for bringing this up !
Description
Using
file.managed
with a remote source (e.g.https://
) usually requires specifying asource_hash
in some way. I would expect it to be used to check if an existing file's contents need to change, which is not the case. Instead, Salt uses this source hash to check if a file downloaded to cache is corrupt only, calculates its source hash and compares it to the existing file.This behavior wastes a lot of resources (CPU cycles, disk space, bandwidth) both locally and on the remote and is completely unnecessary if we already had what we wanted before starting all this work. We're not trying to verify remote sources or manage the cache after all.
Related: #64373
Setup
irrelevant
Steps to Reproduce the behavior
Expected behavior
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Additional context
PR incoming
The text was updated successfully, but these errors were encountered: