Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated backups as explained in documentation overwrites SYSTEMD_WANTS #8641

Closed
httpdev opened this issue Jan 19, 2025 · 2 comments · Fixed by #8642
Closed

Automated backups as explained in documentation overwrites SYSTEMD_WANTS #8641

httpdev opened this issue Jan 19, 2025 · 2 comments · Fixed by #8642

Comments

@httpdev
Copy link
Contributor

httpdev commented Jan 19, 2025

In the documentation for setting up automated backups, the service to autostart is defined by ENV{SYSTEMD_WANTS}= instead of ENV{SYSTEMD_WANTS}+=. This will overwrite other autostart services attached by earlier udev rules.

@httpdev httpdev changed the title Automated backups as explained in documentation overwrite SYSTEMD_WANTS Automated backups as explained in documentation overwrites SYSTEMD_WANTS Jan 19, 2025
httpdev added a commit to httpdev/borg that referenced this issue Jan 19, 2025
…her than overwrite

fixes borgbackup#8641
In the example, setting SYSTEMD_WANTS instead of appending may prevent
other autostart services attached by earlier udev rules from launching.
This commit changes = to += to fix this behavior.
httpdev added a commit to httpdev/borg that referenced this issue Jan 19, 2025
…her than overwrite

fixes borgbackup#8641
In the example, setting SYSTEMD_WANTS instead of appending may prevent
other autostart services attached by earlier udev rules from launching.
This commit changes = to += to fix this behavior.
@ThomasWaldmann
Copy link
Member

Is that the case?

The docs state that the value is ADDED:

https://www.freedesktop.org/software/systemd/man/latest/systemd.device.html#SYSTEMD_WANTS=

@httpdev
Copy link
Contributor Author

httpdev commented Jan 19, 2025

I was curious because the doc does say that it is added, so I ran a test: add another udev rule with higher priority (79-test-a.rules) that sets ENV{SYSTEMD_WANTS}=test-a.service, then check which of the services are run.

Output of udevadm monitor --property with ENV{SYSTEMD_WANTS}= in 80-backup.rules (old behavior)

UDEV  [238217.279129] add      /devices/pci0000:80/0000:80:14.0/usb4/4-6/4-6.1/4-6.1:1.0/host8/target8:0:0/8:0:0:0/block/sda/sda1 (block)
ACTION=add
DEVPATH=/devices/pci0000:80/0000:80:14.0/usb4/4-6/4-6.1/4-6.1:1.0/host8/target8:0:0/8:0:0:0/block/sda/sda1
SUBSYSTEM=block
DEVNAME=/dev/sda1
DEVTYPE=partition
...
ID_PART_ENTRY_DISK=8:0
.LOCAL_ifNum=00
SYSTEMD_WANTS=automatic-backup.service        <----------------
...
TAGS=:systemd:
CURRENT_TAGS=:systemd:

With ENV{SYSTEMD_WANTS}+= in 80-backup.rules (pull request):

UDEV  [238388.798162] add      /devices/pci0000:80/0000:80:14.0/usb4/4-6/4-6.1/4-6.1:1.0/host8/target8:0:0/8:0:0:0/block/sda/sda1 (block)
ACTION=add
DEVPATH=/devices/pci0000:80/0000:80:14.0/usb4/4-6/4-6.1/4-6.1:1.0/host8/target8:0:0/8:0:0:0/block/sda/sda1
SUBSYSTEM=block
DEVNAME=/dev/sda1
DEVTYPE=partition
...
ID_PART_ENTRY_DISK=8:0
.LOCAL_ifNum=00
SYSTEMD_WANTS=test-a.service automatic-backup.service        <----------------
...
TAGS=:systemd:
CURRENT_TAGS=:systemd:

So it appears that SYSTEMD_WANTS is in fact overridden when using "=" and the documentation is wrong or at least misleading. I think the intention might have been to say that the contents of SYSTEMD_WANTS are added but only after all rules have been processed. In that process, SYSTEMD_WANTS can be overridden by other rules. Just to be sure, I have also verified that the test-a.service is not called in the first example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants