[Bug]: mine.update clear=True raises UnboundLocalError on the master and stores nothing
I maintainer di solito rispondono entro 3 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 74/100
Direzione di ricerca
Il bug si trova in RemoteFuncs._mine() in salt/daemons/masterapi.py: data viene assegnato solo nel percorso senza clear, ma la chiamata finale self.cache.store lo usa sempre. Leggi quella funzione e le chiamate di lettura e scrittura della cache, poi riproduci con salt-call mine.update clear=True e controlla salt-run cache.mine. Il lavoro è completo quando clear rimuove le voci obsolete senza UnboundLocalError, clear=False continua a unire i dati, e un test unitario per _mine copre entrambi i percorsi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happened?
RemoteFuncs._mine() only assigns data when clear is false, but always stores data:
So every _mine request with clear: True (only mine.update clear=True sends one; mine.send and the __mine_interval schedule use the default clear=False) fails on the master with:
[salt.master :3541][ERROR ] Error in function _mine:
Traceback (most recent call last):
File ".../salt/master.py", line 3535, in run_func
ret = getattr(self, func)(load)
File ".../salt/master.py", line 3646, in _sync_mine
return self.masterapi._mine(load, skip_verify=False)
File ".../salt/daemons/masterapi.py", line 744, in _mine
self.cache.store(cbank, ckey, data)
UnboundLocalError: cannot access local variable 'data' where it is not associated with a value
(local variable 'data' referenced before assignment on Python 3.10.) Nothing is written, so the old mine entries stay, including ones for functions no longer in mine_functions, and the new data is dropped too. The minion doesn't notice: mine.update returns True once the _minion_mine event is fired, and Minion._mine_send()'s reply from the master is ignored.
This came in with #55760. 5525864060 stored new_data but had a new_ddata typo in the merge branch, and f1e8079486 fixed the typo by changing the store to self.cache.store(cbank, ckey, data), which isn't bound when clearing. Before that (63d8246a5c) the clear path stored load["data"]. Both commits are first in v3000.0rc1, so every release since 3000 has this.
To reproduce, master with default settings (minion_data_cache: True), minion with:
mine_functions:
test.ping: []
test.arg:
- hello
salt-call mine.send stale mine_function=test.echo text=old
salt-call mine.update clear=True
salt-run cache.mine tgt=<minion id>
Expected: only test.arg and test.ping left, since clear is documented as "Specifies whether updating will clear the existing values (True), or whether it will update them (False)". Actual: stale is still there, salt-call returns True and the master logs the traceback above. salt <minion id> mine.update clear=True does the same, and salt <minion id> mine.get <minion id> stale still returns old. salt-run mine.update <minion id> clear=True doesn't hit it, but only because the runner hands clear to LocalClient.cmd() rather than to the function, so the minion runs a plain mine.update (separate bug).
Proposed fix, which is what 5525864060 was going for:
if not load.get("clear", False):
data = self.cache.fetch(cbank, ckey)
if isinstance(data, dict):
data.update(new_data)
- self.cache.store(cbank, ckey, data)
+ new_data = data
+ self.cache.store(cbank, ckey, new_data)
return True
With that applied to the 3008.x master the steps above leave only test.arg and test.ping and nothing is logged; clear=False still merges. There's no test for RemoteFuncs._mine today. I can send a PR against 3008.x with a unit test.
Type of salt install
other (please specify in bug details)
Major version
3006.x, 3007.x, 3008.x
What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)
rockylinux-10
salt --versions-report output
Not a package install: reproduced with salt-master and salt-minion run from
source exports of 3008.x (a98db5df8f, Python 3.14.8), 3007.x (3ee458139d,
Python 3.12.15) and 3006.x (888f452db2, Python 3.11.16) on Rocky Linux 10.2.
Same result on all three; the traceback ends at masterapi.py line 744, 743
and 729 respectively.
RemoteFuncs._mine is identical on 3008.x and master (b78fd91bfe); 3006.x and
3007.x only differ from it in the cache bank/key names.
- Lingua principale
- Python
- Stelle
- 15.8k
- Fork
- 5.6k
- Merge medio
- 5g 9h
- PR unite (30g)
- 99
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di saltstack/salt
-
[Bug]: Scheduled returns scan all accepted minion keys causing extreme loadForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
saltstack/salt#70789 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
[Bug]: pip.installed with upgrade=True upgrades a package but returns an empty changes dictionaryForse già presa @ITJamie l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 3 giorni
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 3 giorni
-
[Bug]: Minion with file_client: local crashes on connect: 'AsyncPillar' object has no attribute 'aclose'Forse già presa @shawnrruss l’ha presa 9 giorni fa. Apertabug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 3 giorni
-
tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di saltstack/salt
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
btclib-org/btclib-wallet#872 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 87/100
btclib-org/btclib#3093 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
patrickballard/wheelgap#269 ·
-
priority: low python
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
LearningCircuit/local-deep-research#8635 ·
I maintainer di solito rispondono entro 1 giorno
-
README says the land/sea mask must match the XS grid; the demo mask does not, and Step 4 worksApertadocumentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
buckai-observatory/Automated-Cloud-Removal-and-Seamless-Satellite-Image-Mosaicking-Pipeline#52 ·
I maintainer di solito rispondono entro 1 giorno