LINBIT / drbd-utils

DRBD userspace utilities (for 9.x, 8.4, 8.3)
GNU General Public License v2.0
79 stars 47 forks source link

Please add "drbdsetup wait-disconnect*" commands as well #21

Closed phmarek closed 2 years ago

phmarek commented 2 years ago

drbdsetup has very nice wait-connect and wait-sync commands; it would be great if there would be more of them, to more easily trigger actions in shell scripts. For example, drbdsetup wait-disconnect-resource would be nice.

Thanks a lot!

lge commented 2 years ago

Hi Philipp :-)

Do I even want to know the details about when exactly you think this would be useful? ;-)

Did you look into using "drbdsetup events2" for that? Or better yet, utilizing https://github.com/LINBIT/drbd-reactor?

phmarek commented 2 years ago

Well, it was a quick one-off encrypted data replication; the SSH tunnel broke down a few times (I believe because of misconfigurations - my fault, didn't do DRBD for too long ;), and so I noticed the asymmetry of the drbdsetup wait- commands.

And no - a separate daemon just because an rsync is running in the background isn't worth the effort. Yeah, drbdsetup events2 | grep ... --line-buffered | head -1 && ... might have worked, but this just shows some inherent complexity that drbdsetup wait- wouldn't have had... ;)

Thanks for the quick help!

rck commented 2 years ago

In this case you are right, drbd-reactor would not have been the right choice. Just in case if somebody else finds this issue in the future: For all things related to drbd state changes and triggering some custom actions, the umh plugin should be a good choice:

The user mode helper is a plugin that allows users to specify filters matched on DRBD state changes. If a filter rule matches, a user defined script gets executed. Information is passed to scripts via environment variables.