Hi Dumitru, regards, Vladislav Odintsov
> On 20 Jan 2023, at 22:51, Dumitru Ceara <[email protected]> wrote: > > On 1/20/23 10:51, Ales Musil wrote: >> On Sat, Jan 14, 2023 at 10:28 AM Vladislav Odintsov <[email protected]> >> wrote: >> >>> With this universal systemd unit users, which run ovsdb-servers with >>> systemd, will be able to run different OVSDB server instances within >>> separate systemd-units. >>> >>> Now it is possible to run all commands from ovn-ctl script, which start >>> and end with "start_/stop_" and "_ovsdb" respectively. Current list is: >>> >>> - ovn-db@sb >>> - ovn-db@nb >>> - ovn-db@ic >>> - ovn-db@ic_sb >>> - ovn-db@ic_nb >>> - ovn-db@sb_relay >>> >>> And any possible future commands, which conform rules described above. >>> >>> To run such units user must define environment variable, which name >>> has a next form: "ovn_%i_opts". Where %i is the name of unit instance >>> (a part after "@" symbol). User may supply this variable with >>> configuration parameter in one of /etc/sysconfig/ovn, >>> /etc/sysconfig/ovn-%i or in >>> /etc/systemd/system/ovn-db@%i.service.d/local.conf files. >>> >>> In general this feature gives more granular process management. For >>> instance, it is not needed to restart SB and NB ovsdb-servers anymore, >>> when user just restarts ovn-northd daemon (upgrade scenario). >>> >>> Signed-off-by: Vladislav Odintsov <[email protected]> >>> --- > > Hi Vladislav, > >>> NEWS | 2 ++ >>> rhel/automake.mk | 1 + >>> rhel/ovn-fedora.spec.in | 31 +++++++++++++++- >>> rhel/[email protected] | 39 +++++++++++++++++++++ >>> 4 files changed, 72 insertions(+), 1 deletion(-) >>> create mode 100644 rhel/[email protected] >>> >>> diff --git a/NEWS b/NEWS >>> index 9aeeac10b..fd0fee75c 100644 >>> --- a/NEWS >>> +++ b/NEWS >>> @@ -3,6 +3,8 @@ Post v22.12.0 >>> - ovn-controller: Experimental support for co-hosting multiple >>> controller >>> instances on the same host. >>> - Add ovn-ctl commands for (re)starting/stopping OVSDB relay for OVN SB >>> DB. >>> + - Add new [email protected] systemd unit to run ovsdb-servers in separate >>> + systemd units. >>> >>> OVN v22.12.0 - 16 Dec 2022 >>> -------------------------- >>> diff --git a/rhel/automake.mk b/rhel/automake.mk >>> index 3e71f5d80..992de3dc7 100644 >>> --- a/rhel/automake.mk >>> +++ b/rhel/automake.mk >>> @@ -13,6 +13,7 @@ EXTRA_DIST += \ >>> rhel/ovn-fedora.spec.in \ >>> rhel/usr_lib_systemd_system_ovn-controller.service \ >>> rhel/usr_lib_systemd_system_ovn-controller-vtep.service \ >>> + rhel/[email protected] \ >>> rhel/usr_lib_systemd_system_ovn-ic.service \ >>> rhel/usr_lib_systemd_system_ovn-ic-db.service \ >>> rhel/usr_lib_systemd_system_ovn-northd.service \ >>> diff --git a/rhel/ovn-fedora.spec.in b/rhel/ovn-fedora.spec.in >>> index 57dc977c1..b41ad062f 100644 >>> --- a/rhel/ovn-fedora.spec.in >>> +++ b/rhel/ovn-fedora.spec.in >>> @@ -165,7 +165,7 @@ install -p -D -m 0644 \ >>> rhel/usr_share_ovn_scripts_systemd_sysconfig.template \ >>> $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/ovn >>> >>> -for service in ovn-controller ovn-controller-vtep ovn-northd ovn-ic >>> ovn-ic-db; do >>> +for service in ovn-controller ovn-controller-vtep ovn-northd ovn-ic >>> ovn-ic-db ovn-db@; do >>> install -p -D -m 0644 \ >>> rhel/usr_lib_systemd_system_${service}.service \ >>> $RPM_BUILD_ROOT%{_unitdir}/${service}.service >>> @@ -265,6 +265,17 @@ if [ $1 -eq 1 ] ; then >>> fi >>> fi >>> >>> +%preun >>> +%if 0%{?systemd_preun:1} >>> + %systemd_preun ovn-db@*.service >>> +%else >>> + if [ $1 -eq 0 ] ; then >>> + # Package removal, not upgrade >>> + /bin/systemctl --no-reload disable ovn-db@*.service >/dev/null >>> 2>&1 || : >>> + /bin/systemctl stop ovn-db@*.service >/dev/null 2>&1 || : >>> + fi >>> +%endif >>> + >>> %preun central >>> %if 0%{?systemd_preun:1} >>> %systemd_preun ovn-northd.service >>> @@ -328,6 +339,15 @@ if [ $1 -eq 1 ]; then >>> fi >>> %endif >>> >>> +%if 0%{?systemd_post:1} >>> + %systemd_post ovn-db@*.service >>> +%else >>> + # Package install, not upgrade >>> + if [ $1 -eq 1 ]; then >>> + /bin/systemctl daemon-reload >dev/null || : >>> + fi >>> +%endif >>> + >>> %post central >>> %if 0%{?systemd_post:1} >>> %systemd_post ovn-northd.service >>> @@ -377,6 +397,11 @@ fi >>> %endif >>> >>> %postun >>> +%if 0%{?systemd_postun:1} >>> + %systemd_postun > > "make rpm-fedora" is failing now: > > error: The %systemd_postun macro requires some arguments > 4< (%error) > 3< (%__systemd_someargs_0) > 2< (%__systemd_someargs_0) > 1< (%expand) > 0< (%systemd_postun) > > Should this be: > > %systemd_postun ovn-db@*.service > > Or something like that? Hmm. Thanks for pointing on this. I’ve checked other macros on fc36 and on el7 systems, but this one was omitted. Actually, I’m not sure wether the argument matters… On el7 system is expands with systemd daemon-reload: $ rpm -E '%systemd_postun ovn-db@*.service' systemctl daemon-reload >/dev/null 2>&1 || : On el8 and fc36 it expands with nothing: ec2-user@ip-10-70-112-12:~/ovn $ rpm -E '%systemd_postun ovn-db@*.service' <empty> Anyway, I’ll address this in v2. > > Thanks, > Dumitru > >>> +%else >>> + /bin/systemctl daemon-reload >/dev/null 2>&1 || : >>> +%endif >>> >>> %postun central >>> %if 0%{?systemd_postun_with_restart:1} >>> @@ -492,6 +517,7 @@ fi >>> %{_mandir}/man5/ovn-ic-sb.5* >>> %{_prefix}/lib/ocf/resource.d/ovn/ovndb-servers >>> %config(noreplace) %{_sysconfdir}/logrotate.d/ovn >>> +%{_unitdir}/[email protected] >>> >>> %files docker >>> %{_bindir}/ovn-docker-overlay-driver >>> @@ -522,6 +548,9 @@ fi >>> %{_unitdir}/ovn-controller-vtep.service >>> >>> %changelog >>> +* Wed Jan 11 2023 Vladislav Odintsov <[email protected]> >>> +- Added [email protected] systemd-unit. >>> + >>> * Mon Feb 1 2021 Vladislav Odintsov <[email protected]> >>> - Added ovn-ic, ovn-ic-db systemd-units. >>> >>> diff --git a/rhel/[email protected] >>> b/rhel/[email protected] >>> new file mode 100644 >>> index 000000000..98556a673 >>> --- /dev/null >>> +++ b/rhel/[email protected] >>> @@ -0,0 +1,39 @@ >>> +# This system unit is used to manage OVN DB daemons. >>> +# It supports all '_ovsdb'-ending commands in >>> +# /usr/share/ovn/scripts/ovn-ctl script. Consult it for additional info. >>> +# >>> +# Each OVN DB systemd unit instance name %i (a part after '@' symbol) >>> must match >>> +# with appropriate ovn-ctl subcommand, which starts and ends with >>> 'start_' and >>> +# '_ovsdb' respectively. >>> +# User must provide appropriate environment variable 'ovn_$i_opts' either >>> in >>> +# /etc/sysconfig/ovn, in /etc/sysconfig/ovn-%i or in >>> +# /etc/systemd/system/ovn-db@%i.service.d/local.conf file. >>> +# >>> +# For example, to configure ovn-db@sb daemon, which runs ovsdb-server >>> with >>> +# OVN_Southbound database schema, you should define variable >>> 'ovn_sb_opts' in >>> +# /etc/systemd/system/[email protected]/local.conf: >>> +# >>> +# [System] >>> +# >>> Environment="ovn_sb_opts=--db-sb-sock=/usr/local/var/run/ovn/ovnsb_db.sock" >>> +# >>> +# Alternatively, you may specify environment variable in the >>> /etc/sysconfig/ovn-sb file: >>> +# >>> +# ovn_sb_opts="--db-sb-sock=/usr/local/var/run/ovn/ovnsb_db.sock" >>> + >>> +[Unit] >>> +Description=OVN database daemon >>> +After=syslog.target >>> + >>> +[Service] >>> +Type=oneshot >>> +RemainAfterExit=yes >>> +Environment=OVN_RUNDIR=%t/ovn OVN_DBDIR=/var/lib/ovn >>> +EnvironmentFile=-/etc/sysconfig/ovn >>> +EnvironmentFile=-/etc/sysconfig/ovn-%i >>> +ExecStartPre=-/usr/bin/chown -R ${OVN_USER_ID} ${OVN_DBDIR} >>> +ExecStart=/usr/share/ovn/scripts/ovn-ctl \ >>> + --ovn-user=${OVN_USER_ID} start_%i_ovsdb $OPTIONS $ovn_%i_opts >>> +ExecStop=/usr/share/ovn/scripts/ovn-ctl stop_%i_ovsdb >>> + >>> +[Install] >>> +WantedBy=multi-user.target >>> -- >>> 2.36.1 >>> >>> _______________________________________________ >>> dev mailing list >>> [email protected] >>> https://mail.openvswitch.org/mailman/listinfo/ovs-dev >>> >>> >> Looks good to me, thanks. >> >> Reviewed-by: Ales Musil <[email protected]> >> > > _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
