mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-01-06 09:01:25 +01:00
Fix: resolve a set of exceptions raised by tempest integration test
Change-Id: I7931f969d93afc28819dff31e2857cfbc6f720ac
This commit is contained in:
parent
a01ef78df3
commit
da03ce9d72
@ -93,6 +93,8 @@ public class DistributedOpenstackNetworkStore
|
||||
private static final String ERR_NOT_FOUND = " does not exist";
|
||||
private static final String ERR_DUPLICATE = " already exists";
|
||||
|
||||
private static final long TIMEOUT_MS = 2000; // wait for 2s
|
||||
|
||||
private static final KryoNamespace SERIALIZER_NEUTRON_L2 = KryoNamespace.newBuilder()
|
||||
.register(KryoNamespaces.API)
|
||||
.register(Network.class)
|
||||
@ -275,11 +277,21 @@ public class DistributedOpenstackNetworkStore
|
||||
|
||||
log.debug("Prepare OpenStack port remove");
|
||||
|
||||
long timeoutExpiredMs = System.currentTimeMillis() + TIMEOUT_MS;
|
||||
|
||||
while (true) {
|
||||
|
||||
long waitMs = timeoutExpiredMs - System.currentTimeMillis();
|
||||
|
||||
if (preCommitPortService.subscriberCountByEventType(
|
||||
portId, OPENSTACK_PORT_PRE_REMOVE) == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (waitMs <= 0) {
|
||||
log.debug("Timeout waiting for port removal.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Versioned<Port> osPort = osPortStore.remove(portId);
|
||||
|
||||
@ -146,6 +146,13 @@ public class InstancePortManager
|
||||
checkArgument(!Strings.isNullOrEmpty(instancePort.portId()),
|
||||
ERR_NULL_INSTANCE_PORT_ID);
|
||||
|
||||
// in case OpenStack removes the port prior to OVS, we will not update
|
||||
// the instance port as it does not exist in the store
|
||||
if (instancePortStore.instancePort(instancePort.portId()) == null) {
|
||||
log.warn("Unable to update instance port {}, as it does not exist", instancePort.portId());
|
||||
return;
|
||||
}
|
||||
|
||||
instancePortStore.updateInstancePort(instancePort);
|
||||
log.info(String.format(MSG_INSTANCE_PORT, instancePort.portId(), MSG_UPDATED));
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.onosproject.openstacknetworking.impl;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.felix.scr.annotations.Activate;
|
||||
@ -430,6 +431,12 @@ public class OpenstackRoutingArpHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (portId == null || fip.getPortId() == null) {
|
||||
log.trace("Unknown target ARP request for {}, ignore it",
|
||||
fip.getFloatingIpAddress());
|
||||
return;
|
||||
}
|
||||
|
||||
InstancePort instPort = instancePortService.instancePort(portId);
|
||||
MacAddress targetMac = instPort.macAddress();
|
||||
|
||||
@ -521,40 +528,46 @@ public class OpenstackRoutingArpHandler {
|
||||
);
|
||||
break;
|
||||
case OPENSTACK_FLOATING_IP_ASSOCIATED:
|
||||
eventExecutor.execute(() -> {
|
||||
NetFloatingIP osFip = event.floatingIp();
|
||||
|
||||
// associate a floating IP with an existing VM
|
||||
setFloatingIpArpRule(event.floatingIp(), event.portId(), completedGws, true);
|
||||
});
|
||||
if (getValidPortId(event) != null) {
|
||||
eventExecutor.execute(() -> {
|
||||
// associate a floating IP with an existing VM
|
||||
setFloatingIpArpRule(event.floatingIp(), getValidPortId(event),
|
||||
completedGws, true);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case OPENSTACK_FLOATING_IP_DISASSOCIATED:
|
||||
eventExecutor.execute(() -> {
|
||||
NetFloatingIP osFip = event.floatingIp();
|
||||
|
||||
// associate a floating IP with an existing VM
|
||||
setFloatingIpArpRule(event.floatingIp(), event.portId(), completedGws, false);
|
||||
});
|
||||
if (getValidPortId(event) != null) {
|
||||
eventExecutor.execute(() -> {
|
||||
// disassociate a floating IP with an existing VM
|
||||
setFloatingIpArpRule(event.floatingIp(), getValidPortId(event),
|
||||
completedGws, false);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case OPENSTACK_FLOATING_IP_CREATED:
|
||||
eventExecutor.execute(() -> {
|
||||
NetFloatingIP osFip = event.floatingIp();
|
||||
|
||||
// during floating IP creation, if the floating IP is
|
||||
// associated with any port of VM, then we will set
|
||||
// floating IP related ARP rules to gateway node
|
||||
setFloatingIpArpRule(osFip, event.portId(), completedGws, true);
|
||||
});
|
||||
// during floating IP creation, if the floating IP is
|
||||
// associated with any port of VM, then we will set
|
||||
// floating IP related ARP rules to gateway node
|
||||
if (getValidPortId(event) != null) {
|
||||
eventExecutor.execute(() -> {
|
||||
// associate a floating IP with an existing VM
|
||||
setFloatingIpArpRule(event.floatingIp(), getValidPortId(event),
|
||||
completedGws, true);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case OPENSTACK_FLOATING_IP_REMOVED:
|
||||
eventExecutor.execute(() -> {
|
||||
NetFloatingIP osFip = event.floatingIp();
|
||||
|
||||
// during floating IP deletion, if the floating IP is
|
||||
// still associated with any port of VM, then we will
|
||||
// remove floating IP related ARP rules from gateway node
|
||||
setFloatingIpArpRule(event.floatingIp(), event.portId(), completedGws, false);
|
||||
});
|
||||
// during floating IP deletion, if the floating IP is
|
||||
// still associated with any port of VM, then we will
|
||||
// remove floating IP related ARP rules from gateway node
|
||||
if (getValidPortId(event) != null) {
|
||||
eventExecutor.execute(() -> {
|
||||
// associate a floating IP with an existing VM
|
||||
setFloatingIpArpRule(event.floatingIp(), getValidPortId(event),
|
||||
completedGws, false);
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// do nothing for the other events
|
||||
@ -562,6 +575,21 @@ public class OpenstackRoutingArpHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private String getValidPortId(OpenstackRouterEvent event) {
|
||||
NetFloatingIP osFip = event.floatingIp();
|
||||
String portId = osFip.getPortId();
|
||||
|
||||
if (Strings.isNullOrEmpty(portId)) {
|
||||
portId = event.portId();
|
||||
}
|
||||
|
||||
if (portId != null && instancePortService.instancePort(portId) != null) {
|
||||
return portId;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Set<IP> getExternalGatewaySnatIps(ExternalGateway extGw) {
|
||||
return osNetworkAdminService.ports().stream()
|
||||
.filter(port ->
|
||||
|
||||
@ -90,7 +90,6 @@ import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.i
|
||||
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.swapStaleLocation;
|
||||
import static org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildExtension;
|
||||
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY;
|
||||
import static org.openstack4j.model.network.NetworkType.FLAT;
|
||||
|
||||
/**
|
||||
* Handles OpenStack floating IP events.
|
||||
@ -204,11 +203,11 @@ public class OpenstackRoutingFloatingIpHandler {
|
||||
if (install) {
|
||||
preCommitPortService.subscribePreCommit(osPort.getId(),
|
||||
OPENSTACK_PORT_PRE_REMOVE, this.getClass().getName());
|
||||
log.info("Subscribed the port pre-remove event");
|
||||
log.info("Subscribed the port {} on listening pre-remove event", osPort.getId());
|
||||
} else {
|
||||
preCommitPortService.unsubscribePreCommit(osPort.getId(),
|
||||
OPENSTACK_PORT_PRE_REMOVE, this.getClass().getName());
|
||||
log.info("Unsubscribed the port pre-remove event");
|
||||
log.info("Unsubscribed the port {} on listening pre-remove event", osPort.getId());
|
||||
}
|
||||
|
||||
updateComputeNodeRules(instPort, osNet, gateway, install);
|
||||
@ -690,6 +689,12 @@ public class OpenstackRoutingFloatingIpHandler {
|
||||
if (osNetworkService.port(osFip.getPortId()) != null) {
|
||||
disassociateFloatingIp(osFip, osFip.getPortId());
|
||||
}
|
||||
|
||||
// since we skip floating IP disassociation, we need to
|
||||
// manually unsubscribe the port pre-remove event
|
||||
preCommitPortService.unsubscribePreCommit(osFip.getPortId(),
|
||||
OPENSTACK_PORT_PRE_REMOVE, this.getClass().getName());
|
||||
log.info("Unsubscribed the port {} on listening pre-remove event", osFip.getPortId());
|
||||
}
|
||||
log.info("Removed floating IP {}", osFip.getFloatingIpAddress());
|
||||
});
|
||||
@ -945,8 +950,7 @@ public class OpenstackRoutingFloatingIpHandler {
|
||||
public boolean isRelevant(OpenstackNetworkEvent event) {
|
||||
// do not allow to proceed without leadership
|
||||
NodeId leader = leadershipService.getLeader(appId.name());
|
||||
return Objects.equals(localNodeId, leader) &&
|
||||
event.subject().getNetworkType() != FLAT;
|
||||
return Objects.equals(localNodeId, leader);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -296,7 +296,7 @@ public class InstancePortManagerTest {
|
||||
/**
|
||||
* Tests if updating an unregistered instance port fails with an exception.
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testUpdateUnregisteredInstancePort() {
|
||||
target.updateInstancePort(instancePort1);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user