mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Don't use context caching for gathering systemd services
In a single Salt run, when multiple pkg states (with accompanying service states) are run, the first service state establishes __context__['systemd.systemd_services']. Then, subsequent pkg states which add new packages will in effect add new systemd services, but systemd.py is oblivious to this change and further attempts to get the list of systemd services are returned from the (now outdated) cache. This commit resolves this by not using context caching for the list of systemd services.
This commit is contained in:
parent
0e2d52c3ea
commit
2d219af67a
1 changed files with 1 additions and 6 deletions
|
@ -125,8 +125,7 @@ def _clear_context():
|
|||
# raise a RuntimeError.
|
||||
for key in list(__context__):
|
||||
try:
|
||||
if key.startswith('systemd._systemctl_status.') \
|
||||
or key in ('systemd.systemd_services',):
|
||||
if key.startswith('systemd._systemctl_status.'):
|
||||
__context__.pop(key)
|
||||
except AttributeError:
|
||||
continue
|
||||
|
@ -178,9 +177,6 @@ def _get_systemd_services():
|
|||
'''
|
||||
Use os.listdir() to get all the unit files
|
||||
'''
|
||||
contextkey = 'systemd.systemd_services'
|
||||
if contextkey in __context__:
|
||||
return __context__[contextkey]
|
||||
ret = set()
|
||||
for path in SYSTEM_CONFIG_PATHS + (LOCAL_CONFIG_PATH,):
|
||||
# Make sure user has access to the path, and if the path is a link
|
||||
|
@ -194,7 +190,6 @@ def _get_systemd_services():
|
|||
continue
|
||||
if unit_type in VALID_UNIT_TYPES:
|
||||
ret.add(unit_name if unit_type == 'service' else fullname)
|
||||
__context__[contextkey] = copy.deepcopy(ret)
|
||||
return ret
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue