Repository navigation
Open
Labels
RequisiteIssue is in Salt's Requisite systembugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone
Description
Description
A state that is prerequired and itself has an onlyif (or unless) requisite that calls an execution module will run regardless of outcome of the onlyif evaluation.
Setup
- on-prem machine
- VM (Virtualbox, KVM, etc. please specify)
- VM running on a cloud service, please be explicit and add details
- container (Kubernetes, Docker, containerd, etc. please specify)
- or a combination, please be explicit
- jails if it is FreeBSD
- classic packaging
- onedir packaging
- used bootstrap to install
Steps to Reproduce the behavior
Copy stuff:
file.copy:
- name: /tmp/aa
- source: /tmp/a
- onlyif:
- fun: file.file_exists
path: /tmp/a
Do sth else:
cmd.run:
- name: true
- prereq:
- Copy stuffExpected behavior
local:
----------
ID: Do sth else
Function: cmd.run
Result: True
Comment: No changes detected
Started: 06:41:33.485261
Duration: 0.007 ms
Changes:
----------
ID: Copy stuff
Function: file.copy
Name: /tmp/aa
Result: True
Comment: onlyif condition is false
Started: 06:41:33.485360
Duration: 8.103 ms
Changes:
Summary for local
------------
Succeeded: 2
Failed: 0
------------
Total states run: 2
Total run time: 8.110 msScreenshots
[WARNING ] no `fun` argument in onlyif: OrderedDict([('path', '/tmp/a')])
[ERROR ] Source file "/tmp/a" is not present
local:
----------
ID: Do sth else
Function: cmd.run
Result: True
Comment: No changes detected
Started: 06:37:15.121723
Duration: 0.008 ms
Changes:
----------
ID: Copy stuff
Function: file.copy
Name: /tmp/aa
Result: False
Comment: Source file "/tmp/a" is not present
Started: 06:37:15.121817
Duration: 80.259 ms
Changes:
Summary for local
------------
Succeeded: 1
Failed: 1
------------
Total states run: 2
Total run time: 80.267 msVersions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3006.3
Python Version:
Python: 3.10.13 (main, Sep 6 2023, 02:11:27) [GCC 11.2.0]
Dependency Versions:
cffi: 1.14.6
cherrypy: unknown
dateutil: 2.8.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.2
libgit2: Not Installed
looseversion: 1.0.2
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.2
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 22.0
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.9.8
pygit2: Not Installed
python-gnupg: 0.4.8
PyYAML: 6.0.1
PyZMQ: 23.2.0
relenv: 0.13.10
smmap: Not Installed
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: rocky 9.2 Blue Onyx
locale: utf-8
machine: x86_64
release: 5.14.0-284.18.1.el9_2.x86_64
system: Linux
version: Rocky Linux 9.2 Blue OnyxAdditional context
The prereq results in the state to be run twice. During the first run, fun (and args) is popped from the passed-in lowstate chunk and is thus unavailable for the second (non-test) run:
Lines 1028 to 1034 in fb717a8
| def _run_check_function(self, entry): | |
| """Format slot args and run unless/onlyif function.""" | |
| fun = entry.pop("fun") | |
| args = entry.pop("args") if "args" in entry else [] | |
| cdata = {"args": args, "kwargs": entry} | |
| self.format_slots(cdata) | |
| return self.functions[fun](*cdata["args"], **cdata["kwargs"]) |
Reacted by lubyou
Metadata
Metadata
Assignees
Labels
RequisiteIssue is in Salt's Requisite systembugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
Activity
OrangeDog commentedon Sep 25, 2023
The lowstate will need to be deep-cloned at an early stage. Hopefully there isn't a feature that relies on being able to change it globally in a state run...
[-][BUG] `prereq`'d state with `onlyif`+ `fun`: onlyif requisite ignored[/-][+][BUG] `prereq`'d state with `onlyif`/`unless` + `fun`: onlyif requisite ignored[/+]Pheric commentedon Nov 1, 2023
This also occurs when using
unlessinstead ofonlyif. Why is this scheduled for Argon?sticky-note commentedon Feb 3, 2024
I think this bugs does not occur any more, the following snippet run correctly in a stateful manner and all cases are correctly covered (
watch_in,prereq_in,require_in,unless) :I just get a warning that is irrelevant as the states and logic runs correctly:
It is great to finally have this kind of
slsrun correctly, it wasn't the case few months agolkubb commentedon Feb 3, 2024
@sticky-note Are you absolutely certain it's running as expected? The
errorlog message is the same as before and is logged just before the instruction is skipped.sticky-note commentedon Feb 4, 2024
In my case, with this code snippet, all cases are handled correctly, I am running:
prereq_inandrequire_inare correctly run when they should and the (AND) condition onunlessalso.The only case when this code snippets does nothing is when all
master_modules_depsare installedANDup to date.Hope this is useful
darkpixel commentedon Dec 13, 2024
There's definitely something odd with requisites going on in some areas:
This runs 100% of the time even when
Get-PackageProviderreturns the NuGet Package Provider info:If I switch it to use
cmd.runit appears to work fine:Unless seems to break with
cmd.powershell.As I understand it,
cmd.powershellreturns a list or dictionary which should evaluate to false if no objects are returned, but also should evaluate to True if any data is returned. I'm guessing there might be something b0rked, but maybe this is unrelated/user-error.b-a-t commentedon Oct 16, 2025
Salt 3006.16 is here. Still for the state like(related to #52256):
I see:
Luckily, the state still works.
3 remaining items
dwoz commentedon Oct 16, 2026
Thanks for the original report. This issue has been open for more than three years without recent activity and carries a severity label below
severity-high. As part of a backlog cleanup, we're closing older low- and medium-severity issues so triage can focus on reports against currently supported releases.Closing isn't a judgement that the problem wasn't real — only that the codebase has moved through several releases since this was filed, and much of the surrounding code has changed.
If you — or anyone else — can still reproduce this on the 3008.x LTS release, please leave a comment with a reproduction and a maintainer will reopen. The original reporter can also reopen directly.
lkubb commentedon Oct 17, 2026
Original reproduction on 3008.3 (I can't reopen myself):
dwoz commentedon Oct 22, 2026
Reopening based on the follow-up comment above.