From patchwork Sat Jan 14 09:28:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1726560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=noWRrlPe; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NvCdP0MjQz23fp for ; Sat, 14 Jan 2023 20:28:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 273A082230; Sat, 14 Jan 2023 09:28:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 273A082230 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=noWRrlPe X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IxgSZWRaxsm9; Sat, 14 Jan 2023 09:28:21 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id DD26382022; Sat, 14 Jan 2023 09:28:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org DD26382022 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D0717C0078; Sat, 14 Jan 2023 09:28:18 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 265B0C0078 for ; Sat, 14 Jan 2023 09:28:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CB0DE400F6 for ; Sat, 14 Jan 2023 09:28:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org CB0DE400F6 Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=noWRrlPe X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id INZESbVcq359 for ; Sat, 14 Jan 2023 09:28:16 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org AC4A3400DD Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by smtp2.osuosl.org (Postfix) with ESMTPS id AC4A3400DD for ; Sat, 14 Jan 2023 09:28:15 +0000 (UTC) Received: by mail-lf1-x133.google.com with SMTP id br9so1036311lfb.4 for ; Sat, 14 Jan 2023 01:28:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=03AzkDGlUt7iiel7uLV0tuVGR/KbyosEH/PSV6KYz0s=; b=noWRrlPeAPJhdHfWXFIE2S/cI9mEmQSOr1b7n6+N5APYHmfEUc3W4d/w0WwUzos7wq E0Rw3uwfc1qpI9SecRJzSJSDwZls/5ENW89PpCG4Lwm+01DkHFSKoLChDd3lvLAk0pGa IxREaPJWGlrp9RWdq1I1MmGM4Cc5drxkYMMCeEkX63WsiAvjrGdOXxBxtQHqzV5wVhQh qjvgyOun9wMDxb228AvTKZKsdfYxWIUoqGNc11fRDjTvNIqCOCwgIVW7c2vpRW3cSFsL MBVDS/LCkxdsLGOY5e9jQH9jNEQYZ1TRGr9FDlOId23PVfUzt47Fg45tVxyamUb8DPeL X7UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=03AzkDGlUt7iiel7uLV0tuVGR/KbyosEH/PSV6KYz0s=; b=sWcHnD+icfpd3CWu6u7lQO9mj7p+i9PoLHUJIF2s5E7D3tpL/9/yKB4StxKozphtAM PUrfC1RIQgnqHjSBWtviwjJo55J/1sFgtSOPsca2X7s/6Anwdk/N6I9oMMvRAmy+1EAI t/HHA+pYziaYDxlJgwaFlewEW980mxRrBXtlvQLRWG/k+Z3JsYGmDsw7zdfatJ9T9mJa 3zENPNDZTp3WtwsazNloDrkZ+I9N3VTKn+Ju2KNscadazgi7zGkl3IoDQ6NUhjOIupYM 8rd4wgJKBXltMMjK6lEqwKhwOKdqZUAu5OInXCiob9sww68BMg1Q+cbOKdKYtKcLFGYw xcnA== X-Gm-Message-State: AFqh2kq3FTQQJj8FDFKO3Rf3JvcFH1UCBc6L8n3C+m38Rda5xinDFTXR NqNZDg6TnW0TxKkUbQ6ihnvZZbNUS+bE5w== X-Google-Smtp-Source: AMrXdXvNj8Ri3aDR0aEGJDsyQWxkSsLrYpmBjrgTsTQFon568/cQGerPnE/xnPV0YYnDvb5vwFQPKQ== X-Received: by 2002:a05:6512:1111:b0:4cc:7e0e:8d5c with SMTP id l17-20020a056512111100b004cc7e0e8d5cmr8886837lfg.37.1673688494704; Sat, 14 Jan 2023 01:28:14 -0800 (PST) Received: from ip-10-70-112-12.vpc-1e810be1.internal (c2-178-216-98-9.elastic.cloud.croc.ru. [178.216.98.9]) by smtp.gmail.com with ESMTPSA id q22-20020a056512211600b0049462af8614sm4271250lfr.145.2023.01.14.01.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Jan 2023 01:28:14 -0800 (PST) From: Vladislav Odintsov To: dev@openvswitch.org Date: Sat, 14 Jan 2023 12:28:06 +0300 Message-Id: <20230114092808.3538014-3-odivlad@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230114092808.3538014-1-odivlad@gmail.com> References: <20230114092808.3538014-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [PATCH ovn v2 2/4] rhel: add ovn-db@.service systemd-unit X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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 Reviewed-by: Ales Musil --- NEWS | 2 ++ rhel/automake.mk | 1 + rhel/ovn-fedora.spec.in | 31 +++++++++++++++- rhel/usr_lib_systemd_system_ovn-db@.service | 39 +++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 rhel/usr_lib_systemd_system_ovn-db@.service 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 ovn-db@.service 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/usr_lib_systemd_system_ovn-db@.service \ 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 +%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}/ovn-db@.service %files docker %{_bindir}/ovn-docker-overlay-driver @@ -522,6 +548,9 @@ fi %{_unitdir}/ovn-controller-vtep.service %changelog +* Wed Jan 11 2023 Vladislav Odintsov +- Added ovn-db@.service systemd-unit. + * Mon Feb 1 2021 Vladislav Odintsov - Added ovn-ic, ovn-ic-db systemd-units. diff --git a/rhel/usr_lib_systemd_system_ovn-db@.service b/rhel/usr_lib_systemd_system_ovn-db@.service new file mode 100644 index 000000000..98556a673 --- /dev/null +++ b/rhel/usr_lib_systemd_system_ovn-db@.service @@ -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/ovn-db@sb.service.d/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