Skip to content

Commit 05ddc19

Browse files
committed
OVS: fix an issue on xenserver
ovs bridges are deleted by xenserver/ovs automatically ``` [root@ref-trl-1797-x-M7-wei-zhou-xs2 ~]# grep -r xapi7 /var/log/ |grep del-br /var/log/xensource.log:Sep 15 07:13:44 ref-trl-1797-x-M7-wei-zhou-xs2 xcp-networkd: [ info|localhost|611 |org.xen.xapi.xenops.classic events D:4a3d931cd89f|network_utils] /usr/bin/ovs-vsctl --timeout=20 -- --if-exists del-br xapi7 /var/log/daemon.log:Sep 15 07:13:45 ref-trl-1797-x-M7-wei-zhou-xs2 ovs-vsctl: ovs|00001|vsctl|INFO|Called as /usr/bin/ovs-vsctl --timeout=20 -- --if-exists del-br xapi7 ``` which results that xe network exists but bridge does not exist, and operation stuck for 20 minutes at ``` 2021-09-15 16:06:56 DEBUG [root] #### VMOPS enter create_tunnel #### 2021-09-15 16:06:56 DEBUG [root] Creating tunnel from host 2 to host 1 with GRE key 2116 2021-09-15 16:06:56 DEBUG [root] Executing:['/usr/bin/ovs-vsctl', '--timeout=0', 'wait-until', 'bridge', 'xapi7', '--', 'get', 'bridge', 'xapi7', 'name'] 2021-09-15 16:26:56 DEBUG [root] bridge xapi7 for creating tunnel - VERIFIED 2021-09-15 16:26:56 DEBUG [root] Executing:['/usr/bin/ovs-vsctl', 'add-port', 'xapi7', 't2116-2-1', '--', 'set', 'interface', 't2116-2-1', 'type=gre', 'options:key=2116', 'options:remote_ip=10.0.34.230'] ```
1 parent 0e9a7dc commit 05ddc19

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -884,33 +884,18 @@ public synchronized Network configureTunnelNetwork(final Connection conn, final
884884
// Invoke plugin to setup the bridge which will be used by this
885885
// network
886886
final String bridge = nw.getBridge(conn);
887-
final Map<String, String> nwOtherConfig = nw.getOtherConfig(conn);
888-
final String configuredHosts = nwOtherConfig.get("ovs-host-setup");
889-
boolean configured = false;
890-
if (configuredHosts != null) {
891-
final String hostIdsStr[] = configuredHosts.split(",");
892-
for (final String hostIdStr : hostIdsStr) {
893-
if (hostIdStr.equals(((Long)hostId).toString())) {
894-
configured = true;
895-
break;
896-
}
897-
}
887+
String result;
888+
if (bridgeName.startsWith("OVS-DR-VPC-Bridge")) {
889+
result = callHostPlugin(conn, "ovstunnel", "setup_ovs_bridge_for_distributed_routing", "bridge", bridge, "key", bridgeName, "xs_nw_uuid", nw.getUuid(conn), "cs_host_id",
890+
((Long)hostId).toString());
891+
} else {
892+
result = callHostPlugin(conn, "ovstunnel", "setup_ovs_bridge", "bridge", bridge, "key", bridgeName, "xs_nw_uuid", nw.getUuid(conn), "cs_host_id", ((Long)hostId).toString());
898893
}
899894

900-
if (!configured) {
901-
String result;
902-
if (bridgeName.startsWith("OVS-DR-VPC-Bridge")) {
903-
result = callHostPlugin(conn, "ovstunnel", "setup_ovs_bridge_for_distributed_routing", "bridge", bridge, "key", bridgeName, "xs_nw_uuid", nw.getUuid(conn), "cs_host_id",
904-
((Long)hostId).toString());
905-
} else {
906-
result = callHostPlugin(conn, "ovstunnel", "setup_ovs_bridge", "bridge", bridge, "key", bridgeName, "xs_nw_uuid", nw.getUuid(conn), "cs_host_id", ((Long)hostId).toString());
907-
}
908-
909-
// Note down the fact that the ovs bridge has been setup
910-
final String[] res = result.split(":");
911-
if (res.length != 2 || !res[0].equalsIgnoreCase("SUCCESS")) {
912-
throw new CloudRuntimeException("Unable to pre-configure OVS bridge " + bridge);
913-
}
895+
// Note down the fact that the ovs bridge has been setup
896+
final String[] res = result.split(":");
897+
if (res.length != 2 || !res[0].equalsIgnoreCase("SUCCESS")) {
898+
throw new CloudRuntimeException("Unable to pre-configure OVS bridge " + bridge);
914899
}
915900
return nw;
916901
} catch (final Exception e) {

scripts/vm/hypervisor/xenserver/ovstunnel

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,16 @@ def setup_ovs_bridge(session, args):
106106
"uuid=%s" % xs_nw_uuid,
107107
"param-name=other-config",
108108
"param-key=ovs-host-setup"])
109-
conf_hosts = cs_host_id + (conf_hosts and ',%s' % conf_hosts or '')
110-
lib.do_cmd([lib.XE_PATH, "network-param-set", "uuid=%s" % xs_nw_uuid,
111-
"other-config:ovs-host-setup=%s" % conf_hosts])
109+
host_found = False
110+
if conf_hosts:
111+
setup_hosts = conf_hosts.split(",")
112+
for host in setup_hosts:
113+
if host == cs_host_id:
114+
host_found = True
115+
if not host_found:
116+
conf_hosts = cs_host_id + (conf_hosts and ',%s' % conf_hosts or '')
117+
lib.do_cmd([lib.XE_PATH, "network-param-set", "uuid=%s" % xs_nw_uuid,
118+
"other-config:ovs-host-setup=%s" % conf_hosts])
112119

113120
# BLOCK IPv6 - Flow spec changes with ovs version
114121
# Temporarily no need BLOCK IPv6
@@ -161,9 +168,16 @@ def setup_ovs_bridge_for_distributed_routing(session, args):
161168
"uuid=%s" % xs_nw_uuid,
162169
"param-name=other-config",
163170
"param-key=ovs-host-setup"])
164-
conf_hosts = cs_host_id + (conf_hosts and ',%s' % conf_hosts or '')
165-
lib.do_cmd([lib.XE_PATH, "network-param-set", "uuid=%s" % xs_nw_uuid,
166-
"other-config:ovs-host-setup=%s" % conf_hosts])
171+
host_found = False
172+
if conf_hosts:
173+
setup_hosts = conf_hosts.split(",")
174+
for host in setup_hosts:
175+
if host == cs_host_id:
176+
host_found = True
177+
if not host_found:
178+
conf_hosts = cs_host_id + (conf_hosts and ',%s' % conf_hosts or '')
179+
lib.do_cmd([lib.XE_PATH, "network-param-set", "uuid=%s" % xs_nw_uuid,
180+
"other-config:ovs-host-setup=%s" % conf_hosts])
167181

168182
# first clear the default rule (rule for 'NORMAL' processing which makes a bridge simple L2 learn & flood switch)
169183
lib.del_flows(bridge, table=0)

0 commit comments

Comments
 (0)