Zygo / bees

Best-Effort Extent-Same, a btrfs dedupe agent
GNU General Public License v3.0
647 stars 55 forks source link

/usr/sbin/beesd does not honor UUID in /etc/bees/beesd.conf #183

Open aaltemara opened 3 years ago

aaltemara commented 3 years ago

Problem:

Expected Behavior:

Also, from looking at the code in /usr/sbin/beesd, it looks like the UUID given as a command-line argument will not be honored if one is also supplied in /etc/bees/*.conf. This is not expected behavior.

Suggested Fix: Within /usr/sbin/beesd, move the command to source /etc/bees/*.conf before the check for a valid UUID. Detect when a UUID is given as an argument, and ensure that takes precedent (or throw an error) when one is also in the config file.

SampsonF commented 3 years ago

beesd@ is a special systemd-unit file. It will take arg as in beesd@arg as the argument of running beesd (as specified in the ExecStart= line)

When we do systemctl enable beesd@arg1 and systemctl enable beesd@arg2, two separate beesd@ services are enabled. And they are using different argument to run their respective arg1.conf, arg2.conf to run.

Only after that, beesd will read the correct UUID from the specified conf file.

georgyo commented 3 years ago

beesd@ is a special systemd-unit file. It will take arg as in beesd@arg as the argument of running beesd (as specified in the ExecStart= line)

When we do systemctl enable beesd@arg1 and systemctl enable beesd@arg2, two separate beesd@ services are enabled. And they are using different argument to run their respective arg1.conf, arg2.conf to run.

Only after that, beesd will read the correct UUID from the specified conf file.

This is how I thought it worked, but that is not how it is actually is configured:

https://github.com/Zygo/bees/blob/081a6af278fc2b4f33198e2ec0028f8383bb6d4a/scripts/beesd%40.service.in#L8

https://github.com/Zygo/bees/blob/081a6af278fc2b4f33198e2ec0028f8383bb6d4a/src/bees-usage.txt#L1-L6

There doesn't seem to be any value at all in beesd.conf, as it does not seem to ever be read currently in a useful way.

The way to start the systemd unit file is with the UUID of the filesystem you want to dedup.

systemctl start beesd@53dbf804-56b5-4d9d-8bd1-13e4bbb405ef
kakra commented 3 years ago

This is how I thought it worked, but that is not how it is actually is configured:

https://github.com/Zygo/bees/blob/081a6af278fc2b4f33198e2ec0028f8383bb6d4a/scripts/beesd%40.service.in#L8

https://github.com/Zygo/bees/blob/081a6af278fc2b4f33198e2ec0028f8383bb6d4a/src/bees-usage.txt#L1-L6

There doesn't seem to be any value at all in beesd.conf, as it does not seem to ever be read currently in a useful way.

Please take note of this difference:

bees is the actual binary which does the work and expects a file system path.

beesd is a wrapper script which converts the UUID to a path and reads the config file, then passes everything to bees.

But TBH, this is not very well documented, and beesd also just passes the help parameter over to bees.

The way to start the systemd unit file is with the UUID of the filesystem you want to dedup.

systemctl start beesd@53dbf804-56b5-4d9d-8bd1-13e4bbb405ef

Yes, that's true. Because it runs beesd instead of bees directly.