<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font face="Gentium">Hello Alexander,</font></p>
<p><font face="Gentium">you're right, catching up with all the
running session and restoring the full internal state would be a
nightmare. I think it is doable but too difficult (and
labour-costly) to get it right. Regarding the need for graceful
restart support anyway, I don't see much of a good reason to
prefer this over a regular graceful restart.<br>
</font></p>
<p><font face="Gentium">Maria</font><br>
</p>
<div class="moz-cite-prefix">On 6/21/23 13:41, Alexander Zubkov
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CABr+u0ZHyoGdhTbZkSQcuT7HYa2Z6Kzsxjuv_EDYnxdEi-Nw0Q@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="auto">
<div>Hello Maria,</div>
<div dir="auto"><br>
</div>
<div dir="auto">Regarding restarts, I think the killer feature
might be some sort of restart, when bird execs a new binary,
keeping all the file descriptors open and its state somehow.
So the new instance could transparently catch up with all the
running sessions, etc. It can serialize the internal state
somehow and then reinitialize it from that. But I'm afraid it
would require a great effort to implement something like that.</div>
<div dir="auto"><br>
<div class="gmail_quote" dir="auto">
<div dir="ltr" class="gmail_attr">On Wed, Jun 21, 2023,
08:58 Maria Matejka via Bird-users <<a
href="mailto:bird-users@network.cz"
moz-do-not-send="true" class="moz-txt-link-freetext">bird-users@network.cz</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello
Daniel, <br>
<br>
On 21 June 2023 01:03:50 CEST, "Daniel Gröber" <<a
href="mailto:dxld@darkboxed.org" target="_blank"
rel="noreferrer" moz-do-not-send="true"
class="moz-txt-link-freetext">dxld@darkboxed.org</a>>
wrote:<br>
>Hi Erin,<br>
><br>
>On Tue, Jun 20, 2023 at 08:20:50PM +0200, Erin
Shepherd wrote:<br>
>> I run bird on a system which uses systemd as a
service supervisor, and<br>
>> would like to implement graceful restart in a way
which works well with<br>
>> it.<br>
><br>
>I'm also interested in getting this working. I'm
wondering how graceful<br>
>restart is supposed to behave to begin with though.
Last time I just tried<br>
>`birdc graceful restart` I was surprised that this
actually makes bird exit<br>
>with rv=0 instead of ... well actually restarting.<br>
><br>
>Is that normal or a bug in the Debian
packaging/systemd service?<br>
<br>
You're supposed to start BIRD again on your terms. It's a
misleading command wording, kind of. I don't know whether
it's a good idea to actually exec from the shutdown cycle.
Will think about it. It may be a nice feature.<br>
<br>
>I suppose if you're supposed to use graceful restart
just before rebooting<br>
>the system it makes sense but at the time I just
wanted to do a full<br>
>restart to update the running bird executable without
causing traffic<br>
>disruption and was rather surprised when it didn't
come back up.<br>
<br>
Yes, these two different use cases were what we were
choosing from when implementing this.<br>
<br>
<br>
>> In particular, what I'd like to do is:<br>
>> • If I restart the bird service (e.g. for an
upgrade), Bird performs a graceful restart<br>
>> • If I manually stop bird (systemctl stop
bird2), shutdown the system, or any other action which is
liable to cause a longer period of downtime, perform a
graceful restart (for BGP at least)<br>
><br>
>When you want to tickle special behaviour out of
systemd I found it best to<br>
>not try and do everything in one unit. Using the
dependency system you can<br>
>stop another unit before bird.service gets stopped,
this can then call<br>
>birdc graceful restart, like this:<br>
><br>
>bird-graceful-restart.service:<br>
><br>
> [Unit]<br>
> After=bird.service<br>
> Requires=bird.service<br>
> [Service]<br>
> Type=oneshot<br>
> RemainAfterExit=yes<br>
> ExecStop=birdc graceful restart<br>
> [Install]<br>
> WantedBy=bird.service<br>
><br>
>That way you can enable/disable system wide graceful
bird restart by<br>
>`systemctl enable bird-graceful-restart.service`.<br>
><br>
>The BindsTo+After means stopping bird.service (which
is part of restart)<br>
>will first stop bird-graceful-restart.service, which
can then casually<br>
>signal bird to perform graceful restart without a race
(I<br>
>think). WanteBy=bird.service is needed as ExecStop
will only run when a<br>
>service has actually been started.<br>
><br>
>Also some special handling for the case where bird is
already gone (crashed<br>
>or exited) and birdc would fail might be needed.
Excercise for the reader :)<br>
><br>
>Doing some quick testing this actually seems to do
what I want. Somewhat<br>
>unexpectedly `systemctl restart bird.servce` with the
above enabled does<br>
>then actually do what you'd expect since restart is
just stop+start. Bird<br>
>will exit on getting the graceful restart command so
systemd can't try to<br>
>stop it some more but the subsequent start will make
it come back up. Neat.<br>
><br>
>On system shutdown only the stop part will happen so
bird exiting is<br>
>actully useful now and that too should work as
expected.<br>
<br>
If there was somebody to implement this additional Systemd
unit and provide it as a patch, we'd happily merge it.<br>
<br>
Thank you for all the ideas!<br>
Maria<br>
<br>
-- <br>
Maria Matejka (she/her) | BIRD Team Leader | CZ.NIC,
z.s.p.o.<br>
<br>
</blockquote>
</div>
</div>
</div>
</blockquote>
<pre class="moz-signature" cols="72">--
Maria Matejka (she/her) | BIRD Team Leader | CZ.NIC, z.s.p.o.</pre>
</body>
</html>