Fix: wait for creation of patch ports which are on tenant bridges

Resolve a NPE issue caused when missing name attribute in status
object in VirtualMachineInstance

Change-Id: I1315a63bbaae250abcc4ed6cec92fb1ed160dfd8
(cherry picked from commit dd4041e154a2850d48ed44800a7189cd04df0e6d)
This commit is contained in:
Jian Li 2021-06-30 20:59:43 +09:00
parent f3a3c5acd2
commit 56f241be23
2 changed files with 22 additions and 1 deletions

View File

@ -297,6 +297,19 @@ public class KubevirtSecurityGroupHandler {
private void initializeTenantAclTable(KubevirtNetwork network,
DeviceId deviceId, boolean install) {
// FIXME: in bridge initialization phase, some patch ports may not be
// available until they are created, we wait for a while ensure all
// patch ports are created via network bootstrap
while (true) {
if (network.tenantToTunnelPort(deviceId) != null) {
break;
} else {
log.info("Wait for tenant patch ports creation for device {} " +
"and network {}", deviceId, network.networkId());
waitFor(5);
}
}
PortNumber patchPort = network.tenantToTunnelPort(deviceId);
initializeAclTable(deviceId, TENANT_ACL_RECIRC_TABLE, patchPort, install);
}

View File

@ -357,7 +357,15 @@ public final class KubevirtNetworkingUtil {
Set<KubevirtPort> ports = new HashSet<>();
for (JsonNode interfaceJson : interfacesJson) {
String name = interfaceJson.get(NAME).asText();
JsonNode jsonName = interfaceJson.get(NAME);
// in some cases, name attribute may not be available from the
// interface, we skip inspect this interface
if (jsonName == null) {
continue;
}
String name = jsonName.asText();
KubevirtNetwork network = networks.stream()
.filter(n -> (NETWORK_PREFIX + n.name()).equals(name) ||
(n.name() + "-net").equals(name))