Ignore extend declarations from excluded sls files

sls files that are excluded should not affect other sls files by
extending their states. Exclude statements are processed very late in
the state processing pipeline to ensure they are not overridden. By that
time, extend declarations are already processed.

Luckily, it's not necessary to change much, during the extend
declarations processing it is easy to check if the sls file that
contains a given extend declaration is excluded.
This commit is contained in:
Alexander Graul 2022-10-11 14:55:51 +02:00
parent e91c1a608b
commit 856b23c45d
No known key found for this signature in database
GPG key ID: 1FFD172C26318181
2 changed files with 20 additions and 0 deletions

1
changelog/62082.fixed Normal file
View file

@ -0,0 +1 @@
Ignore extend declarations in sls files that are excluded.

View file

@ -1685,6 +1685,25 @@ class State:
else:
name = ids[0][0]
sls_excludes = []
# excluded sls are plain list items or dicts with an "sls" key
for exclude in high.get("__exclude__", []):
if isinstance(exclude, str):
sls_excludes.append(exclude)
elif exclude.get("sls"):
sls_excludes.append(exclude["sls"])
if body.get("__sls__") in sls_excludes:
log.debug(
"Cannot extend ID '%s' in '%s:%s' because '%s:%s' is excluded.",
name,
body.get("__env__", "base"),
body.get("__sls__", "base"),
body.get("__env__", "base"),
body.get("__sls__", "base"),
)
continue
for state, run in body.items():
if state.startswith("__"):
continue