CS-14724 : Making the default network label configurable, improving exception management

Please also see notes added to wiki.cloudstack.org/display/QA/Open+vSwitch+Tunnel+Manager
This commit is contained in:
Salvatore Orlando 2012-05-02 13:14:47 +01:00
parent 9b1fd4d414
commit 486d962f09
5 changed files with 41 additions and 18 deletions

View File

@ -4945,22 +4945,23 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
private OvsFetchInterfaceAnswer execute(OvsFetchInterfaceCommand cmd) {
String label = cmd.getLabel();
s_logger.debug("### Will look for network with name-label:" + label + " on host " + _host.ip);
s_logger.debug("Will look for network with name-label:" + label + " on host " + _host.ip);
Connection conn = getConnection();
try {
XsLocalNetwork nw = this.getNetworkByName(conn, label);
s_logger.debug("### Network object:" + nw.getNetwork().getUuid(conn));
s_logger.debug("Network object:" + nw.getNetwork().getUuid(conn));
PIF pif = nw.getPif(conn);
Record pifRec = pif.getRecord(conn);
s_logger.debug("### PIF object:" + pifRec.uuid + "(" + pifRec.device + ")");
s_logger.debug("PIF object:" + pifRec.uuid + "(" + pifRec.device + ")");
return new OvsFetchInterfaceAnswer(cmd, true, "Interface " + pifRec.device + " retrieved successfully",
pifRec.IP, pifRec.netmask, pifRec.MAC);
} catch (Exception e) {
e.printStackTrace();
s_logger.error("An error occurred while fetching the interface for " +
label + " on host " + _host.ip + ":" + e.toString() +
"(" + e.getClass() + ")");
return new OvsFetchInterfaceAnswer(cmd, false, "EXCEPTION:" + e.getMessage());
}
}
@ -4985,6 +4986,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
}
} catch (Exception e) {
e.printStackTrace();
s_logger.error("An error occurred while creating a GRE tunnel to " +
cmd.getRemoteIp() + " on host " + _host.ip + ":" + e.getMessage() +
"(" + e.getClass() + ")");
}
return new OvsCreateGreTunnelAnswer(cmd, false, "EXCEPTION", _host.ip, bridge);

View File

@ -88,7 +88,8 @@ public enum Config {
NetworkThrottlingRate("Network", ManagementServer.class, Integer.class, "network.throttling.rate", "200", "Default data transfer rate in megabits per second allowed in network.", null),
GuestDomainSuffix("Network", AgentManager.class, String.class, "guest.domain.suffix", "cloud.internal", "Default domain name for vms inside virtualized networks fronted by router", null),
DirectNetworkNoDefaultRoute("Network", ManagementServer.class, Boolean.class, "direct.network.no.default.route", "false", "Direct Network Dhcp Server should not send a default route", "true/false"),
OvsTunnelNetwork("Network", ManagementServer.class, Boolean.class, "sdn.ovs.controller", "false", "enable/disable open vswitch tunnel network(no vlan)", null),
OvsTunnelNetwork("Network", ManagementServer.class, Boolean.class, "sdn.ovs.controller", "false", "Enable/Disable Open vSwitch SDN controller for L2-in-L3 overlay networks", null),
OvsTunnelNetworkDefaultLabel("Network", ManagementServer.class, String.class, "sdn.ovs.controller.default.label", "cloud-public", "Default network label to be used when fetching interface for GRE endpoints", null),
VmNetworkThrottlingRate("Network", ManagementServer.class, Integer.class, "vm.network.throttling.rate", "200", "Default data transfer rate in megabits per second allowed in User vm's default network.", null),
NetworkLockTimeout("Network", ManagementServer.class, Integer.class, "network.lock.timeout", "600", "Lock wait timeout (seconds) while implementing network", null),

View File

@ -138,10 +138,19 @@ public class OvsTunnelManagerImpl implements OvsTunnelManager {
private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId){
OvsFetchInterfaceAnswer ans = (OvsFetchInterfaceAnswer) answers[0];
OvsTunnelInterfaceVO ti =
createInterfaceRecord(ans.getIp(), ans.getNetmask(),
ans.getMac(), hostId, ans.getLabel());
return ti.getIp();
if (ans.getResult()) {
if (ans.getIp() != null &&
!("".equals(ans.getIp()))) {
OvsTunnelInterfaceVO ti =
createInterfaceRecord(ans.getIp(), ans.getNetmask(),
ans.getMac(), hostId, ans.getLabel());
return ti.getIp();
}
}
// Fetch interface failed!
s_logger.warn("Unable to fetch the IP address for the GRE tunnel endpoint" +
ans.getDetails());
return null;
}
private void handleCreateTunnelAnswer(Answer[] answers){
@ -177,10 +186,8 @@ public class OvsTunnelManagerImpl implements OvsTunnelManager {
private String getGreEndpointIP(Host host, Network nw) throws
AgentUnavailableException, OperationTimedoutException {
String endpointIp = null;
// Fetch physical network and associated tags
// If no tag specified, look for this network
// Default name for network label
String physNetLabel = "cloud-public";
// Fetch fefault name for network label from configuration
String physNetLabel = _configDao.getValue(Config.OvsTunnelNetworkDefaultLabel.key());
Long physNetId = nw.getPhysicalNetworkId();
PhysicalNetworkTrafficType physNetTT =
_physNetTTDao.findBy(physNetId, TrafficType.Guest);
@ -313,13 +320,21 @@ public class OvsTunnelManagerImpl implements OvsTunnelManager {
}
}
}
//FIXME: Why are we cancelling the exception here?
//TODO: Should we propagate the exception here?
try {
String myIp = getGreEndpointIP(dest.getHost(), nw);
if (myIp == null)
throw new GreTunnelException("Unable to retrieve the source " +
"endpoint for the GRE tunnel." +
"Failure is on host:" + dest.getHost().getId());
boolean noHost = true;
for (Long i : toHostIds) {
HostVO rHost = _hostDao.findById(i);
String otherIp = getGreEndpointIP(rHost, nw);
if (otherIp == null)
throw new GreTunnelException("Unable to retrieve the remote " +
"endpoint for the GRE tunnel." +
"Failure is on host:" + rHost.getId());
Commands cmds = new Commands(
new OvsCreateTunnelCommand(otherIp, key,
Long.valueOf(hostId), i, nw.getId(), myIp));
@ -354,7 +369,8 @@ public class OvsTunnelManagerImpl implements OvsTunnelManager {
handleSetupBridgeAnswer(answers);
}
} catch (Exception e) {
s_logger.debug("Ovs Tunnel network created tunnel failed", e);
// I really thing we should do a better handling of these exceptions
s_logger.warn("Ovs Tunnel network created tunnel failed", e);
}
}

View File

@ -24,7 +24,8 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'manag
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'secstorage.service.offering', NULL, 'Service offering used by secondary storage; if NULL - system offering will be used');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'sdn.ovs.controller', NULL, 'Enabled Open vSwitch SDN controller for L2-in-L3 overlay networks');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'sdn.ovs.controller', NULL, 'Enable/Disable Open vSwitch SDN controller for L2-in-L3 overlay networks');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'sdn.ovs.controller.default.label', NULL, 'Default network label to be used when fetching interface for GRE endpoints');
ALTER TABLE `cloud`.`user_vm` ADD COLUMN `update_parameters` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Defines if the parameters need to be set for the vm';
UPDATE `cloud`.`user_vm` SET update_parameters=0 where id>0;

View File

@ -3,7 +3,7 @@
# the following two variables are used by the target "waf dist"
# if you change 'em here, you need to change it also in cloud.spec, add a %changelog entry there, and add an entry in debian/changelog
VERSION = '3.0.3.2012-05-02T00:07:57Z'
VERSION = '3.0.3'
APPNAME = 'cloud'
import shutil,os