[systemd-devel] how to properly control the daemons or run advanced cmds

Flavio Leitner fbl at redhat.com
Tue Nov 25 07:58:22 PST 2014


On Tue, Nov 25, 2014 at 10:42:12AM +0000, Richard Maw wrote:
> On Tue, Nov 25, 2014 at 12:09:07AM -0200, Flavio Leitner wrote:
> > 
> > Hello,
> > 
> > The Open vSwitch is comprised by two daemons. One is a database and
> > another is the switch itself.
> > 
> > Currently we have the openvswitch.service which start/stop/reload the
> > service (both daemons) just fine.
> > 
> > However, we need to support hot-upgrade which means to stop the
> > vswitch daemon first, run a few special commands, reload the db
> > daemon and only then start the vswitch daemon.
> > 
> > I know about creating shell helpers for non-standard commands, but
> > since that needs to mess up with the daemons in a particular order,
> > I think systemd won't like the above external actions at all.
> > 
> > Any suggestion on how to handle this with systemd properly?
> 
> We've previously had discussion on how to handle hot-upgrade, though I
> don't remember enough details to find the message again.
> 
> I think the resolution was that the daemon in question must either
> re-exec itself, or have NotifyAccess=all set in the systemd unit, and
> it must notify systemd of the PID of the new version of the daemon by
> sending MAINPID=$NEWPID with sd_notify.

This is the current status output. Notice that everything is initialized
by a script passing all the parameters and initializing other things if
needed as well.

$ systemctl -l status openvswitch-nonetwork
openvswitch-nonetwork.service - Open vSwitch Internal Unit
   Loaded: loaded (/usr/lib/systemd/system/openvswitch-nonetwork.service; static)
   Active: active (exited) since Mon 2014-11-24 09:38:58 BRST; 1 day 3h ago
 Main PID: 1683 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/openvswitch-nonetwork.service
           ├─1795 ovsdb-server: monitoring pid 1796 (healthy)                                                
           ├─1796 ovsdb-server /etc/openvswitch/conf.db -vconsole:emer -vsyslog:err -vfile:info --remote=punix:/var/run/openvswitch/db.sock --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --no-chdir --log-file=/var/log/openvswitch/ovsdb-server.log --pidfile=/var/run/openvswitch/ovsdb-server.pid --detach --monitor
           ├─1806 ovs-vswitchd: monitoring pid 1807 (healthy)
           └─1807 ovs-vswitchd unix:/var/run/openvswitch/db.sock -vconsole:emer -vsyslog:err -vfile:info --mlockall --no-chdir --log-file=/var/log/openvswitch/ovs-vswitchd.log --pidfile=/var/run/openvswitch/ovs-vswitchd.pid --detach --monitor


Since I need to stop completely vswitchd, then restart the ovsdb,
then run some commands and only after that start the vswitchd daemon,
it doesn't look like re-exec'ing itself will work or I am missing
something.

> Unless you overload ExecReload to mean hot-upgrade/graceful-reexec then
> you'll have to have an external tool instruct the service to upgrade
> itself, rather than issuing a `systemctl reload vswitch.service`.

It doesn't seem to be a good idea because it will surprise the users
in a bad way.  Those steps are required only for hot-upgrade or force
kernel module reloading which are unusual.

Thanks
fbl


More information about the systemd-devel mailing list