Merge "[ovs] Start ovs services before networking"
[fuel.git] / mcp / patches / salt-formula-linux / 0003-OVS-Fix-Debian-service-deps-OVS-bridge-ifup.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2019 Mirantis Inc., Enea AB and others.
3 :
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
10 Date: Fri, 25 Jan 2019 21:20:04 +0100
11 Subject: [PATCH] OVS: Fix Debian service deps, OVS bridge ifup
12
13 Fix OVS vs Linux bridge race condition:
14 - OVS services should start before networking service;
15 - OVS services should start after DPDK service (if present);
16 - networking service should ifup OVS bridges (and automatically their
17   OVS ports if present) after Linux interfaces/bridges;
18 - br-prv should be handled by OVS to avoid another race condition,
19   so use 'allow-ovs br-prv' instead of 'auto';
20
21 NOTE:
22 - OVS ports/bridges should NOT be configured as auto for this to work;
23 - OVS services correspond to OVS 2.9 or newer, since before that
24   ovsdb-server was called openvswitch-nonetwork.
25 - we also need to take care of one particularly ugly circular dep:
26   ovs-vswitchd --> ovsdb-server -(default dep)-> sysinit.target -->
27   cloud-init.service --> networking.service --> ovs-vswitchd
28   We'll just set 'DefaultDependencies=no' for ovs services, although
29   this might require explicitly adding back some of the indirect
30   dependencies of sysinit.target.
31
32 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
33 ---
34  linux/network/dpdk.sls      |  2 +-
35  linux/network/interface.sls | 36 ++++++++++++++++++++++++++++++++++++
36  2 files changed, 37 insertions(+), 1 deletion(-)
37
38 diff --git a/linux/network/dpdk.sls b/linux/network/dpdk.sls
39 index 09453c6..e866909 100644
40 --- a/linux/network/dpdk.sls
41 +++ b/linux/network/dpdk.sls
42 @@ -199,7 +199,7 @@ linux_network_dpdk_bridge_interface_{{ interface_name }}:
43  /etc/network/interfaces.u/ifcfg-{{ interface_name }}:
44    file.managed:
45      - contents: |
46 -        auto {{ interface_name }}
47 +        allow-ovs {{ interface_name }}
48          iface {{ interface_name }} inet static
49          address {{ interface.address }}
50          netmask {{ interface.netmask }}
51 diff --git a/linux/network/interface.sls b/linux/network/interface.sls
52 index 8bce092..11db5be 100644
53 --- a/linux/network/interface.sls
54 +++ b/linux/network/interface.sls
55 @@ -24,6 +24,42 @@ linux_network_bridge_pkgs:
56    - pkgs: {{ network.bridge_pkgs }}
57    {%- endif %}
58
59 +{%- if network.bridge == 'openvswitch' and grains.os_family == 'Debian' %}
60 +
61 +{# create drop-in dpdk, networking dependency for ovs services #}
62 +/etc/systemd/system/ovsdb-server.service.d/override.conf:
63 +  file.managed:
64 +    - makedirs: true
65 +    - require:
66 +      - pkg: linux_network_bridge_pkgs
67 +    - contents: |
68 +        [Unit]
69 +        After=dpdk.service
70 +        Before=networking.service
71 +        DefaultDependencies=no
72 +
73 +/etc/systemd/system/ovs-vswitchd.service.d/override.conf:
74 +  file.managed:
75 +    - makedirs: true
76 +    - require:
77 +      - pkg: linux_network_bridge_pkgs
78 +    - contents: |
79 +        [Unit]
80 +        Before=networking.service
81 +        DefaultDependencies=no
82 +
83 +{# Debian/Ubuntu won't automatically ifup OVS bridges, workaround #}
84 +/etc/systemd/system/networking.service.d/ovs_workaround.conf:
85 +  file.managed:
86 +    - makedirs: true
87 +    - require:
88 +      - pkg: linux_network_bridge_pkgs
89 +    - contents: |
90 +        [Service]
91 +        ExecStart=/sbin/ifup --allow=ovs -a --read-environment
92 +
93 +{%- endif %}
94 +
95  {%- endif %}
96
97  {%- for f in network.get('concat_iface_files', []) %}