You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
As per the documentation, the systemd_service module can detect if unit files were changed and a daemon-reload is necessary, so there is no need to add service.systemctl_reload if you also already have a service.running.
Though the check if a daemon-reload is needed just happens once (the first time), even if there are multiple occasions for the same service where it could be needed.
For example if you have two SLS files: a.sls changes /etc/systemd/system/dummy.service.d/a.conf and does a service.running for "dummy" to activate the change by restart b.sls changes /etc/systemd/system/dummy.service.d/b.conf and also does a service.running for "dummy" for the same reason
Both work fine if applied alone.
But if you for example execute them both in a highstate, the daemon-reload is only done after the first change but not after the second change.
It is stores in __context__ that it has already checked if daemon-reload is needed.
If called again for the same service, it doesn't check anymore.
I don't know the reason for why it is done this way.
But maybe the __context__ part could simply be removed?
Setup
Here is an example SLS for demonstration that include two tasks that could be split in two separate SLS files:
creates and starts a dummy service
adds additional systemd config and restarts dummy service
create-dummy-service:
file.managed:
- name: /etc/systemd/system/dummy.service
- contents: | [Unit] Description = Dummy [Service] ExecStart = /bin/bash -c "while [ 1 ]; do sleep 1 ; done"start-dummy-service:
service.running:
- name: dummy# to show if daemon-reload warning is in status output (visible in stderr) -> will show nothingtest-status-1:
cmd.run:
- name: "systemctl status dummy >/dev/null"# change unit config/etc/systemd/system/dummy.service.d/restart.conf:
file.managed:
- makedirs: True
- contents: | # Timestamp as dummy change: {{ salt.system.get_system_date_time() }} [Service] Restart=on-failure# to show if daemon-reload warning is in status output (visible in stderr) -> will show necessary daemon-reload because of changetest-status-2:
cmd.run:
- name: "systemctl status dummy >/dev/null"# restart on changerestart-salt-minion:
service.running:
- name: dummy
- watch:
- file: /etc/systemd/system/dummy.service.d/restart.conf# to show if daemon-reload warning is in status output (visible in stderr) -> will still show necessary daemon-reloadtest-status-3:
cmd.run:
- name: "systemctl status dummy >/dev/null"
VM (Virtualbox, KVM, etc. please specify)
container (Kubernetes, Docker, containerd, etc. please specify)
onedir packaging
Expected behavior
systemd_service should detect if a daemon-reload is needed on every invocation.
Versions Report
salt --versions-report
Salt Version:
Salt: 3006.9Python Version:
Python: 3.10.14 (main, Jun 26 2024, 11:44:37) [GCC 11.2.0]Dependency Versions:
cffi: 1.14.6cherrypy: unknowncryptography: 42.0.5dateutil: 2.8.1docker-py: Not Installedgitdb: Not Installedgitpython: Not InstalledJinja2: 3.1.4libgit2: Not Installedlooseversion: 1.0.2M2Crypto: Not InstalledMako: Not Installedmsgpack: 1.0.2msgpack-pure: Not Installedmysql-python: Not Installedpackaging: 22.0pycparser: 2.21pycrypto: Not Installedpycryptodome: 3.19.1pygit2: Not Installedpython-gnupg: 0.4.8PyYAML: 6.0.1PyZMQ: 23.2.0relenv: 0.17.0smmap: Not Installedtimelib: 0.2.4Tornado: 4.5.3ZMQ: 4.3.4System Versions:
dist: ubuntu 22.04.4 jammylocale: utf-8machine: x86_64release: 5.15.153.1-microsoft-standard-WSL2system: Linuxversion: Ubuntu 22.04.4 jammy
The text was updated successfully, but these errors were encountered:
Description
As per the documentation, the systemd_service module can detect if unit files were changed and a daemon-reload is necessary, so there is no need to add service.systemctl_reload if you also already have a service.running.
Though the check if a daemon-reload is needed just happens once (the first time), even if there are multiple occasions for the same service where it could be needed.
For example if you have two SLS files:
a.sls changes /etc/systemd/system/dummy.service.d/a.conf and does a service.running for "dummy" to activate the change by restart
b.sls changes /etc/systemd/system/dummy.service.d/b.conf and also does a service.running for "dummy" for the same reason
Both work fine if applied alone.
But if you for example execute them both in a highstate, the daemon-reload is only done after the first change but not after the second change.
Here is the relevant code section:
salt/salt/modules/systemd_service.py
Lines 133 to 143 in b40833e
It is stores in __context__ that it has already checked if daemon-reload is needed.
If called again for the same service, it doesn't check anymore.
I don't know the reason for why it is done this way.
But maybe the __context__ part could simply be removed?
Setup
Here is an example SLS for demonstration that include two tasks that could be split in two separate SLS files:
Expected behavior
systemd_service should detect if a daemon-reload is needed on every invocation.
Versions Report
salt --versions-report
The text was updated successfully, but these errors were encountered: