[systemd-devel] "primary" Condition for drbd?
Brian Masney
bmasney at redhat.com
Thu Jun 13 16:49:45 UTC 2024
On Thu, Jun 13, 2024 at 10:08 AM Lennart Poettering
<lennart at poettering.net> wrote:
> On Do, 13.06.24 11:27, Harald Dunkel (harald.dunkel at aixigo.com) wrote:
> > I missed to mention, drbdadm does know:
> >
> > # drbdadm role space
> > Primary/Secondary
> >
> > meaning "space" is primary on this host. You can also look
> > at /proc/drbd:
> >
> > # cat /proc/drbd
> > version: 8.4.11 (api:1/proto:86-101)
> > srcversion: 19D914EA50F713FCCE48607
> >
> > 1: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
> > ns:4044664 nr:0 dw:4044664 dr:726481 al:188 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
> > 2: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
> > ns:0 nr:2228224 dw:2228224 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
> > 3: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
> > ns:699492 nr:0 dw:699492 dr:266197 al:75 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
> >
> > Problem is, it doesn't say "/dev/drbd1". "space" and "1" are
> > defined in drbd's config files, mapping it to "/dev/drbd1". To
> > evaluate the condition you have to perform a pretty complex
> > task.
>
> Youre are assuming that people know what drbd is and does, and what
> "primary" or "secondary" means in the context. I certainly have no
> clue.
>
> > Does systemd allow to run a program to evaluate a custom
> > condition in a unit file? Maybe I am too blind to see, but
> > I haven't found it mentioned on https://www.freedesktop.org/\
> > software/systemd/man/latest/systemd.unit.html.
>
> There's ExecCondition=. But what would you use it for?
>
> ExecCondition= is intended for quick checks.
>
> > The context is: I want to mount/activate /dev/drbd1, if it is
> > primary. (If it is not, then /dev/drbd1 should be silently
> > ignored.) Next I want to start the LXC containers provided by
> > the virtual block device, and setup networking and storage
> > accordingly. The same should happen for /dev/dbrd{2..n}.
>
> I have no idea what this all means, but I have the suspicion you
> actually want a generator, i.e. a plugin to systemd that adds some
> deps depending on external configuration files.
>
> i.e. implement this stuff:
>
> https://www.freedesktop.org/software/systemd/man/latest/systemd.generator.html
Note: It's been 17 years or so since I last used drbd, so my knowledge
here is very dated. drbd is a replicated block storage device where
you can have two identical machines and replicate a block device
between them. You can run it in several modes and the mode that's
described in this thread is where one system is the primary and the
other acts as a hot standby (the secondary) that can take over the
shared IP address if the primary system fails. I don't think the
generators are what Harald needs. A parser will need to be written for
/proc/drbd and then ExecCondition= can be used, and is described by
the man page systemd.service(5).
However, I'd recommend checking with the upstream drbd developers to
see what they recommend.
Brian
More information about the systemd-devel
mailing list