Grains cache ignores grain exceptions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description of Issue
This issue is debatable, but I wasted some amount of time debugging a grain problem. In the end my custom grain was faulty, but grains_cache: True masked this fault.
What has happened:
- A custom grain failed with an exception (and I haven't noticed this)
- With
grains_cache: Truethe grains were cached without this faulty grain - Subsequent
grains.getcalls returned an empty grain (because it wasn't cached) and the minion log was clear of any exceptions
What is expected:
If there were any exceptions when the grains were collected, the result should not be cached at all (i.e. the cache should be invalid and the next run should try to refresh the grains again). If any of the grains has failed, the error should be visible each time you run grains.get, even with caching enabled.
Steps to Reproduce Issue
- Add a custom grain that raises any exception, sync it to the minion
- Set
grains_cache: Truein a minion config - Run
salt-call --local -l debug grains.get yourcustomgrainmultiple times. - The exception will be visible only on the first run, then the grain is just empty and no errors is visible in the log
Versions Report
Happens at least on 2018.3.4 and 2019.2.0.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior with a custom grain that raises an exception, grains_cache: True, and repeated salt-call --local -l debug grains.get yourcustomgrain runs. Trace grain collection and cache handling from the grains.get entry point; done means failed collection results are not cached and the exception remains visible on subsequent calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100