From patchwork Fri Nov 3 20:39:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timothy Redaelli X-Patchwork-Id: 834087 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yTDMj0RF8z9s4s for ; Sat, 4 Nov 2017 07:39:28 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B7AFBD96; Fri, 3 Nov 2017 20:39:26 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 83523D7A for ; Fri, 3 Nov 2017 20:39:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CCD83500 for ; Fri, 3 Nov 2017 20:39:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3900777356; Fri, 3 Nov 2017 20:39:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3900777356 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=tredaelli@redhat.com Received: from graphite.redhat.com (ovpn-116-30.ams2.redhat.com [10.36.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77D225C54A; Fri, 3 Nov 2017 20:39:23 +0000 (UTC) From: Timothy Redaelli To: dev@openvswitch.org Date: Fri, 3 Nov 2017 21:39:17 +0100 Message-Id: <2581edbb76687fa9b2baf9c1ac87031e8ac075f8.1509741252.git.tredaelli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 03 Nov 2017 20:39:24 +0000 (UTC) X-Spam-Status: No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: fbl@sysclose.org Subject: [ovs-dev] [PATCH v2] rhel: Add support for "systemctl reload openvswitch" X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org The reload procedure will trigger a script that saves the flows and tlv maps (using ovs-save) then it restarts ovsdb-server, it stops ovs-vswitchd, it sets other_config:flow-restore-wait=true (to wait till flow restore is finished), it starts ovs-vswitchd, it restore the backupped flows/tlv maps and it removes other_config:flow-restore-wait=true (logic mostly ripped from ovs-ctl). It uses systemctl with --job-mode=ignore-dependencies to restart ovsdb-server and stop and start ovs-vswitchd in order to avoid systemd to restart the other components due to dependencies (as explained in rhel/README.RHEL.rst). Signed-off-by: Timothy Redaelli Acked-by: Flavio Leitner --- v1->v2: * Renamed the script from ovs-reload to ovs-systemd-reload (as suggested by Flavio Leitner) --- rhel/automake.mk | 1 + rhel/openvswitch-fedora.spec.in | 5 +++ rhel/usr_lib_systemd_system_openvswitch.service | 2 +- rhel/usr_lib_systemd_system_ovsdb-server.service | 1 - ...sr_share_openvswitch_scripts_ovs-systemd-reload | 36 ++++++++++++++++++++++ 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 rhel/usr_share_openvswitch_scripts_ovs-systemd-reload diff --git a/rhel/automake.mk b/rhel/automake.mk index 9336f0912..137ff4a39 100644 --- a/rhel/automake.mk +++ b/rhel/automake.mk @@ -24,6 +24,7 @@ EXTRA_DIST += \ rhel/openvswitch.spec.in \ rhel/openvswitch-fedora.spec \ rhel/openvswitch-fedora.spec.in \ + rhel/usr_share_openvswitch_scripts_ovs-systemd-reload \ rhel/usr_share_openvswitch_scripts_sysconfig.template \ rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \ rhel/usr_lib_udev_rules.d_91-vfio.rules \ diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in index fb7d918c6..b45e018f5 100644 --- a/rhel/openvswitch-fedora.spec.in +++ b/rhel/openvswitch-fedora.spec.in @@ -314,6 +314,10 @@ install -d -m 0755 $RPM_BUILD_ROOT%{_prefix}/lib/ocf/resource.d/ovn ln -s %{_datadir}/openvswitch/scripts/ovndb-servers.ocf \ $RPM_BUILD_ROOT%{_prefix}/lib/ocf/resource.d/ovn/ovndb-servers +install -p -D -m 0755 \ + rhel/usr_share_openvswitch_scripts_ovs-systemd-reload \ + $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/ovs-systemd-reload + # remove unpackaged files rm -f $RPM_BUILD_ROOT%{_bindir}/ovs-parse-backtrace \ $RPM_BUILD_ROOT%{_sbindir}/ovs-vlan-bug-workaround \ @@ -539,6 +543,7 @@ fi %{_datadir}/openvswitch/scripts/ovs-save %{_datadir}/openvswitch/scripts/ovs-vtep %{_datadir}/openvswitch/scripts/ovs-ctl +%{_datadir}/openvswitch/scripts/ovs-systemd-reload %config %{_datadir}/openvswitch/vswitch.ovsschema %config %{_datadir}/openvswitch/vtep.ovsschema %{_bindir}/ovs-appctl diff --git a/rhel/usr_lib_systemd_system_openvswitch.service b/rhel/usr_lib_systemd_system_openvswitch.service index faca44b54..feaba37d5 100644 --- a/rhel/usr_lib_systemd_system_openvswitch.service +++ b/rhel/usr_lib_systemd_system_openvswitch.service @@ -9,7 +9,7 @@ Requires=ovs-vswitchd.service [Service] Type=oneshot ExecStart=/bin/true -ExecReload=/bin/true +ExecReload=/usr/share/openvswitch/scripts/ovs-systemd-reload ExecStop=/bin/true RemainAfterExit=yes diff --git a/rhel/usr_lib_systemd_system_ovsdb-server.service b/rhel/usr_lib_systemd_system_ovsdb-server.service index 5baac822d..234d39355 100644 --- a/rhel/usr_lib_systemd_system_ovsdb-server.service +++ b/rhel/usr_lib_systemd_system_ovsdb-server.service @@ -3,7 +3,6 @@ Description=Open vSwitch Database Unit After=syslog.target network-pre.target Before=network.target network.service Wants=ovs-delete-transient-ports.service -ReloadPropagatedFrom=openvswitch.service PartOf=openvswitch.service [Service] diff --git a/rhel/usr_share_openvswitch_scripts_ovs-systemd-reload b/rhel/usr_share_openvswitch_scripts_ovs-systemd-reload new file mode 100755 index 000000000..3ac1a46c6 --- /dev/null +++ b/rhel/usr_share_openvswitch_scripts_ovs-systemd-reload @@ -0,0 +1,36 @@ +#! /bin/sh + +# Copyright (c) 2017 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Save flows +bridges=$(ovs-vsctl -- --real list-br) +flows=$(/usr/share/openvswitch/scripts/ovs-save save-flows $bridges) + +# Restart the database first, since a large database may take a +# while to load, and we want to minimize forwarding disruption. +systemctl --job-mode=ignore-dependencies restart ovsdb-server + +# Stop ovs-vswitchd. +systemctl --job-mode=ignore-dependencies stop ovs-vswitchd + +# Start vswitchd by asking it to wait till flow restore is finished. +ovs-vsctl --no-wait set open_vswitch . other_config:flow-restore-wait=true +systemctl --job-mode=ignore-dependencies start ovs-vswitchd + +# Restore saved flows and inform vswitchd that we are done. +eval "$flows" +ovs-vsctl --if-exists remove open_vswitch . other_config flow-restore-wait=true + +exit 0