Browse Source

Fix OVS-related issues with underlay networking

* more intelligent calculation of default port provider
* additional check of patchcord existing in the bridge

OVS provider should be used for fake (OVS) ports, inserted
into OVS bridge. OVS provider should be used for inserting
native linux interface into OVS bridge.

But if we try to add native linux subinterface into
OVS bridge we should use lnx provider for creating
such port correctly.

Change-Id: Ib76b3340eca1ea22095da1cfffe7c224a139fb71
Closes-bug: #1682835
changes/81/458881/3
Sergey Vasilenko 2 years ago
parent
commit
d096bfe121

+ 3
- 1
deployment/puppet/l23network/lib/puppet/parser/functions/generate_network_config.rb View File

@@ -419,7 +419,9 @@ Puppet::Parser::Functions::newfunction(:generate_network_config, :type => :rvalu
419 419
         end
420 420
 
421 421
         if !trans[:provider]
422
-          if action == :port && trans[:bridge]
422
+          if action == :port && trans[:bridge] && ((trans[:vlan_dev] && trans[:vlan_id]) or trans[:name]=~/\.\d+/)
423
+            trans[:provider] = default_provider
424
+          elsif action == :port && trans[:bridge]
423 425
             provider = L23network.get_property_for_transformation('PROVIDER', trans[:bridge], lookupvar('l3_fqdn_hostname'))
424 426
             trans[:provider] = provider || default_provider
425 427
           else

+ 173
- 0
deployment/puppet/l23network/spec/classes/l2_lnx_subinterfaces_into_ovs_bridge__spec.rb View File

@@ -0,0 +1,173 @@
1
+require 'spec_helper'
2
+
3
+describe 'l23network::examples::run_network_scheme', :type => :class do
4
+  context 'network scheme with OVS bridge and native lnx subinterface with ethN.XXX naming into it' do
5
+    let(:title) { 'test network scheme' }
6
+    let(:facts) {
7
+      {
8
+        :osfamily => 'Debian',
9
+        :operatingsystem => 'Ubuntu',
10
+        :kernel => 'Linux',
11
+        :l23_os => 'ubuntu',
12
+        :l3_fqdn_hostname => 'stupid_hostname',
13
+      }
14
+    }
15
+
16
+    let(:params) {{
17
+      :settings_yaml => '''
18
+        network_scheme:
19
+          version: 1.1
20
+          provider: lnx
21
+          interfaces:
22
+            eth1: {}
23
+          transformations:
24
+            - action: add-br
25
+              name: xxx
26
+              provider: ovs
27
+            - action: add-port
28
+              name: eth1.101
29
+              bridge: xxx
30
+      '''
31
+    }}
32
+
33
+    before(:each) do
34
+      puppet_debug_override()
35
+    end
36
+
37
+    it { is_expected.to compile.with_all_deps }
38
+    it { is_expected.to contain_l23network__l2__port('eth1.101') }
39
+    it { is_expected.to contain_l23network__l2__port('eth1.101').with({
40
+        'provider'  => 'lnx',
41
+    })}
42
+  end
43
+end
44
+
45
+describe 'l23network::examples::run_network_scheme', :type => :class do
46
+  context 'network scheme with OVS bridge and native lnx subinterface with vlanXXX naming into it' do
47
+    let(:title) { 'test network scheme' }
48
+    let(:facts) {
49
+      {
50
+        :osfamily => 'Debian',
51
+        :operatingsystem => 'Ubuntu',
52
+        :kernel => 'Linux',
53
+        :l23_os => 'ubuntu',
54
+        :l3_fqdn_hostname => 'stupid_hostname',
55
+      }
56
+    }
57
+
58
+    let(:params) {{
59
+      :settings_yaml => '''
60
+        network_scheme:
61
+          version: 1.1
62
+          provider: lnx
63
+          interfaces:
64
+            eth1: {}
65
+          transformations:
66
+            - action: add-br
67
+              name: xxx
68
+              provider: ovs
69
+            - action: add-port
70
+              name: vlan101
71
+              vlan_dev: eth1
72
+              vlan_id: 101
73
+              bridge: xxx
74
+      '''
75
+    }}
76
+
77
+    before(:each) do
78
+      puppet_debug_override()
79
+    end
80
+
81
+    it { is_expected.to compile.with_all_deps }
82
+    it { is_expected.to contain_l23network__l2__port('vlan101') }
83
+    it { is_expected.to contain_l23network__l2__port('vlan101').with({
84
+        'provider'  => 'lnx',
85
+    })}
86
+  end
87
+end
88
+
89
+describe 'l23network::examples::run_network_scheme', :type => :class do
90
+  context 'network scheme with OVS bridge and native lnx interface into it' do
91
+    let(:title) { 'test network scheme' }
92
+    let(:facts) {
93
+      {
94
+        :osfamily => 'Debian',
95
+        :operatingsystem => 'Ubuntu',
96
+        :kernel => 'Linux',
97
+        :l23_os => 'ubuntu',
98
+        :l3_fqdn_hostname => 'stupid_hostname',
99
+      }
100
+    }
101
+
102
+    let(:params) {{
103
+      :settings_yaml => '''
104
+        network_scheme:
105
+          version: 1.1
106
+          provider: lnx
107
+          interfaces:
108
+            eth1: {}
109
+          transformations:
110
+            - action: add-br
111
+              name: xxx
112
+              provider: ovs
113
+            - action: add-port
114
+              name: eth1
115
+              bridge: xxx
116
+      '''
117
+    }}
118
+
119
+    before(:each) do
120
+      puppet_debug_override()
121
+    end
122
+
123
+    it { is_expected.to compile.with_all_deps }
124
+    it { is_expected.to contain_l23network__l2__port('eth1') }
125
+    it { is_expected.to contain_l23network__l2__port('eth1').with({
126
+        'provider'  => 'ovs',
127
+    })}
128
+  end
129
+end
130
+
131
+describe 'l23network::examples::run_network_scheme', :type => :class do
132
+  context 'network scheme with OVS bridge and ovs fake interface into it' do
133
+    let(:title) { 'test network scheme' }
134
+    let(:facts) {
135
+      {
136
+        :osfamily => 'Debian',
137
+        :operatingsystem => 'Ubuntu',
138
+        :kernel => 'Linux',
139
+        :l23_os => 'ubuntu',
140
+        :l3_fqdn_hostname => 'stupid_hostname',
141
+      }
142
+    }
143
+
144
+    let(:params) {{
145
+      :settings_yaml => '''
146
+        network_scheme:
147
+          version: 1.1
148
+          provider: lnx
149
+          interfaces:
150
+            eth1: {}
151
+          transformations:
152
+            - action: add-br
153
+              name: xxx
154
+              provider: ovs
155
+            - action: add-port
156
+              name: yyy
157
+              bridge: xxx
158
+      '''
159
+    }}
160
+
161
+    before(:each) do
162
+      puppet_debug_override()
163
+    end
164
+
165
+    it { is_expected.to compile.with_all_deps }
166
+    it { is_expected.to contain_l23network__l2__port('yyy') }
167
+    it { is_expected.to contain_l23network__l2__port('yyy').with({
168
+        'provider'  => 'ovs',
169
+    })}
170
+  end
171
+end
172
+
173
+###

+ 15
- 0
files/fuel-ha-utils/ocf/ns_IPaddr2 View File

@@ -475,6 +475,19 @@ ip_stop() {
475 475
   return $rc
476 476
 }
477 477
 
478
+check_patchcord_exists_in_bridge() {
479
+  local br="$1"
480
+  local veth="$2"
481
+  if [[ -d /sys/class/net/${br}/brif ]] ; then
482
+    # LNX
483
+    test -L  /sys/class/net/${br}/brif/${veth} || return $OCF_ERR_GENERIC
484
+  else
485
+    # OVS
486
+    ovs-vsctl list-ports "${br}" | grep "${veth}" || return $OCF_ERR_GENERIC
487
+  fi
488
+  return $OCF_SUCCESS
489
+}
490
+
478 491
 ip_monitor() {
479 492
   local rc
480 493
   ip_validate
@@ -483,6 +496,8 @@ ip_monitor() {
483 496
 
484 497
   [ -z "$iface" ] && return $OCF_NOT_RUNNING
485 498
 
499
+  check_patchcord_exists_in_bridge $OCF_RESKEY_bridge $OCF_RESKEY_base_veth || return $OCF_ERR_GENERIC
500
+
486 501
   check_interfaces_for_up_state "$OCF_RESKEY_bridge:$OCF_RESKEY_also_check_interfaces" || return $OCF_NOT_RUNNING
487 502
   # use arping here, because no IP from VIP network allowed on host system
488 503
   ocf_run arping -c 10 -w 2 -I $OCF_RESKEY_bridge $OCF_RESKEY_ip || return $OCF_NOT_RUNNING

Loading…
Cancel
Save