Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite timeouts in ovs-vsctl (Closes: #1000137) #266

Merged
merged 2 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/openvswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ write_ovs_systemd_unit(const char* id, const GString* cmds, const char* rootdir,
g_string_append_printf(s, "After=netplan-ovs-%s.service\n", dependency);
}

g_string_append(s, "\n[Service]\nType=oneshot\n");
g_string_append(s, "\n[Service]\nType=oneshot\nTimeoutStartSec=10s\n");
g_string_append(s, cmds->str);

g_string_free_to_file(s, rootdir, path, NULL);
Expand Down
4 changes: 2 additions & 2 deletions tests/generator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
Bridge %(iface)s external-ids:netplan/mcast_snooping_enable=false\nExecStart=/usr/bin/ovs-vsctl set Bridge %(iface)s \
rstp_enable=false\nExecStart=/usr/bin/ovs-vsctl set Bridge %(iface)s external-ids:netplan/rstp_enable=false\n'
OVS_BR_EMPTY = _OVS_BASE + 'After=netplan-ovs-cleanup.service\nBefore=network.target\nWants=network.target\n\n[Service]\n\
Type=oneshot\nExecStart=/usr/bin/ovs-vsctl --may-exist add-br %(iface)s\n' + OVS_BR_DEFAULT
Type=oneshot\nTimeoutStartSec=10s\nExecStart=/usr/bin/ovs-vsctl --may-exist add-br %(iface)s\n' + OVS_BR_DEFAULT
OVS_CLEANUP = _OVS_BASE + 'ConditionFileIsExecutable=/usr/bin/ovs-vsctl\nBefore=network.target\nWants=network.target\n\n\
[Service]\nType=oneshot\nExecStart=/usr/sbin/netplan apply --only-ovs-cleanup\n'
[Service]\nType=oneshot\nTimeoutStartSec=10s\nExecStart=/usr/sbin/netplan apply --only-ovs-cleanup\n'
UDEV_MAC_RULE = 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="%s", ATTR{address}=="%s", NAME="%s"\n'
UDEV_NO_MAC_RULE = 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="%s", NAME="%s"\n'
UDEV_SRIOV_RULE = 'ACTION=="add", SUBSYSTEM=="net", ATTRS{sriov_totalvfs}=="?*", RUN+="/usr/sbin/netplan apply --sriov-only"\n'
Expand Down
29 changes: 29 additions & 0 deletions tests/generator/test_ovs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def test_interface_external_ids_other_config(self):
self.assert_ovs({'ovs0.service': OVS_VIRTUAL % {'iface': 'ovs0', 'extra': '''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br ovs0
ExecStart=/usr/bin/ovs-vsctl --may-exist add-port ovs0 eth1
ExecStart=/usr/bin/ovs-vsctl --may-exist add-port ovs0 eth0
Expand All @@ -60,6 +61,7 @@ def test_interface_external_ids_other_config(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl set Interface eth0 external-ids:iface-id=myhostname
ExecStart=/usr/bin/ovs-vsctl set Interface eth0 external-ids:netplan/external-ids/iface-id=myhostname
ExecStart=/usr/bin/ovs-vsctl set Interface eth0 other-config:disable-in-band=true
Expand All @@ -71,6 +73,7 @@ def test_interface_external_ids_other_config(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl set Interface eth1 other-config:disable-in-band=false
ExecStart=/usr/bin/ovs-vsctl set Interface eth1 external-ids:netplan/other-config/disable-in-band=false
'''},
Expand Down Expand Up @@ -109,6 +112,7 @@ def test_global_external_ids_other_config(self):
self.assert_ovs({'global.service': OVS_VIRTUAL % {'iface': 'global', 'extra': '''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl set open_vswitch . external-ids:iface-id=myhostname
ExecStart=/usr/bin/ovs-vsctl set open_vswitch . external-ids:netplan/external-ids/iface-id=myhostname
ExecStart=/usr/bin/ovs-vsctl set open_vswitch . other-config:disable-in-band=true
Expand All @@ -129,6 +133,7 @@ def test_global_set_protocols(self):
self.assert_ovs({'ovs0.service': OVS_VIRTUAL % {'iface': 'ovs0', 'extra': '''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br ovs0
''' + OVS_BR_DEFAULT % {'iface': 'ovs0'} + '''\
ExecStart=/usr/bin/ovs-vsctl set Bridge ovs0 protocols=OpenFlow10,OpenFlow11,OpenFlow12
Expand Down Expand Up @@ -185,6 +190,7 @@ def test_bond_setup(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-bond br0 bond0 eth1 eth2
ExecStart=/usr/bin/ovs-vsctl set Port bond0 external-ids:netplan=true
ExecStart=/usr/bin/ovs-vsctl set Port bond0 lacp=off
Expand Down Expand Up @@ -253,6 +259,7 @@ def test_bond_lacp(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-bond br0 bond0 eth1 eth2
ExecStart=/usr/bin/ovs-vsctl set Port bond0 external-ids:netplan=true
ExecStart=/usr/bin/ovs-vsctl set Port bond0 lacp=active
Expand Down Expand Up @@ -318,6 +325,7 @@ def test_bond_mode_implicit_params(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-bond br0 bond0 eth1 eth2
ExecStart=/usr/bin/ovs-vsctl set Port bond0 external-ids:netplan=true
ExecStart=/usr/bin/ovs-vsctl set Port bond0 lacp=off
Expand Down Expand Up @@ -357,6 +365,7 @@ def test_bond_mode_explicit_params(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-bond br0 bond0 eth1 eth2
ExecStart=/usr/bin/ovs-vsctl set Port bond0 external-ids:netplan=true
ExecStart=/usr/bin/ovs-vsctl set Port bond0 lacp=off
Expand Down Expand Up @@ -408,6 +417,7 @@ def test_bridge_setup(self):
'''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br br0
ExecStart=/usr/bin/ovs-vsctl --may-exist add-port br0 eth1
ExecStart=/usr/bin/ovs-vsctl --may-exist add-port br0 eth2
Expand All @@ -432,6 +442,7 @@ def test_bridge_external_ids_other_config(self):
self.assert_ovs({'br0.service': OVS_VIRTUAL % {'iface': 'br0', 'extra': '''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br br0
''' + OVS_BR_DEFAULT % {'iface': 'br0'} + '''\
ExecStart=/usr/bin/ovs-vsctl set Bridge br0 external-ids:iface-id=myhostname
Expand Down Expand Up @@ -462,6 +473,7 @@ def test_bridge_non_default_parameters(self):
'''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br br0
ExecStart=/usr/bin/ovs-vsctl --may-exist add-port br0 eth1
ExecStart=/usr/bin/ovs-vsctl --may-exist add-port br0 eth2
Expand Down Expand Up @@ -521,6 +533,7 @@ def test_bridge_set_protocols(self):
'''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br br0
''' + OVS_BR_DEFAULT % {'iface': 'br0'} + '''\
ExecStart=/usr/bin/ovs-vsctl set Bridge br0 protocols=OpenFlow10,OpenFlow11,OpenFlow15
Expand Down Expand Up @@ -570,6 +583,7 @@ def test_bridge_controller(self):
'''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br br0
''' + OVS_BR_DEFAULT % {'iface': 'br0'} + '''\
ExecStart=/usr/bin/ovs-vsctl set-controller br0 ptcp: ptcp:1337 ptcp:1337:[fe80::1234%eth0] pssl:1337:[fe80::1] ssl:10.10.10.1 \
Expand All @@ -583,6 +597,7 @@ def test_bridge_controller(self):
'global.service': OVS_VIRTUAL % {'iface': 'global', 'extra': '''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl set-ssl /key/path /some/path /another/path
ExecStart=/usr/bin/ovs-vsctl set open_vswitch . external-ids:netplan/global/set-ssl=/key/path,/some/path,/another/path
'''},
Expand Down Expand Up @@ -680,6 +695,7 @@ def test_global_ssl(self):
self.assert_ovs({'global.service': OVS_VIRTUAL % {'iface': 'global', 'extra': '''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl set-ssl /key/path /some/path /another/path
ExecStart=/usr/bin/ovs-vsctl set open_vswitch . external-ids:netplan/global/set-ssl=/key/path,/some/path,/another/path
'''},
Expand Down Expand Up @@ -784,6 +800,7 @@ def test_bridge_auto_ovs_backend(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-bond br0 bond0 eth1 eth2
ExecStart=/usr/bin/ovs-vsctl set Port bond0 external-ids:netplan=true
ExecStart=/usr/bin/ovs-vsctl set Port bond0 lacp=off
Expand Down Expand Up @@ -832,6 +849,7 @@ def test_bond_auto_ovs_backend(self):
'br1.service': OVS_VIRTUAL % {'iface': 'br1', 'extra': '''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br br1
ExecStart=/usr/bin/ovs-vsctl --may-exist add-port br1 patchx -- set Interface patchx type=patch options:peer=patchy
''' + OVS_BR_DEFAULT % {'iface': 'br1'}},
Expand All @@ -841,6 +859,7 @@ def test_bond_auto_ovs_backend(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-bond br0 bond0 patchy eth0 -- set Interface patchy type=patch options:peer=patchx
ExecStart=/usr/bin/ovs-vsctl set Port bond0 external-ids:netplan=true
ExecStart=/usr/bin/ovs-vsctl set Port bond0 lacp=off
Expand All @@ -852,6 +871,7 @@ def test_bond_auto_ovs_backend(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl set Port patchx external-ids:netplan=true
'''},
'patchy.service': OVS_VIRTUAL % {'iface': 'patchy', 'extra':
Expand All @@ -860,6 +880,7 @@ def test_bond_auto_ovs_backend(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl set Interface patchy external-ids:netplan=true
'''},
'cleanup.service': OVS_CLEANUP % {'iface': 'cleanup'}})
Expand Down Expand Up @@ -887,12 +908,14 @@ def test_patch_ports(self):
self.assert_ovs({'br0.service': OVS_VIRTUAL % {'iface': 'br0', 'extra': '''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br br0
ExecStart=/usr/bin/ovs-vsctl --may-exist add-port br0 patch0-1 -- set Interface patch0-1 type=patch options:peer=patch1-0
''' + OVS_BR_DEFAULT % {'iface': 'br0'}},
'br1.service': OVS_VIRTUAL % {'iface': 'br1', 'extra': '''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br br1
ExecStart=/usr/bin/ovs-vsctl --may-exist add-port br1 patch1-0 -- set Interface patch1-0 type=patch options:peer=patch0-1
''' + OVS_BR_DEFAULT % {'iface': 'br1'}},
Expand All @@ -902,6 +925,7 @@ def test_patch_ports(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl set Port patch0-1 external-ids:netplan=true
'''},
'patch1-0.service': OVS_VIRTUAL % {'iface': 'patch1-0', 'extra':
Expand All @@ -910,6 +934,7 @@ def test_patch_ports(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl set Port patch1-0 external-ids:netplan=true
'''},
'cleanup.service': OVS_CLEANUP % {'iface': 'cleanup'}})
Expand All @@ -934,6 +959,7 @@ def test_fake_vlan_bridge_setup(self):
self.assert_ovs({'br0.service': OVS_VIRTUAL % {'iface': 'br0', 'extra': '''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br br0
''' + OVS_BR_DEFAULT % {'iface': 'br0'}},
'br0.100.service': OVS_VIRTUAL % {'iface': 'br0.100', 'extra':
Expand All @@ -942,6 +968,7 @@ def test_fake_vlan_bridge_setup(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br br0.100 br0 100
ExecStart=/usr/bin/ovs-vsctl set Interface br0.100 external-ids:netplan=true
'''},
Expand Down Expand Up @@ -971,6 +998,7 @@ def test_implicit_fake_vlan_bridge_setup(self):

[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br br0.100 br0 100
ExecStart=/usr/bin/ovs-vsctl set Interface br0.100 external-ids:netplan=true
'''},
Expand Down Expand Up @@ -1007,6 +1035,7 @@ def test_bridge_non_ovs_bond(self):
self.assert_ovs({'ovs-br.service': OVS_VIRTUAL % {'iface': 'ovs-br', 'extra': '''
[Service]
Type=oneshot
TimeoutStartSec=10s
ExecStart=/usr/bin/ovs-vsctl --may-exist add-br ovs-br
ExecStart=/usr/bin/ovs-vsctl --may-exist add-port ovs-br non-ovs-bond
''' + OVS_BR_DEFAULT % {'iface': 'ovs-br'}},
Expand Down
Loading