From 8269060d93ca555673ac5b913b0868f726c81dd1 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Sat, 11 May 2019 18:27:55 +0000 Subject: [PATCH] VPC: Fail to restart VPC with cleanup if there are multiple public IPs in different subnet" Step to reproduce: (1) create vpc, source nat IP is 10.11.118.X (2) assign two public IPs in other subnet to this VPC. 10.11.119.X and 10.11.119.Y (3) deploy two vms in the vpc, and enable static nat 10.11.119.X and 10.11.119.Y to these two vms (4) restart vpc with cleanup. Operation fails due to there are more than 1 nic allocated for 10.11.119 to new VRs 2019-05-10 14:12:24,652 DEBUG [o.a.c.e.o.NetworkOrchestrator] (API-Job-Executor-36:ctx-839f6522 job-652 ctx-35fb4667) (logid:1ab7aa37) Allocating nic for vm VM[DomainRouter|r-85-VM] in network Ntwk[200|Public|1] with requested profile NicProfile[0-0-null-10.11.118.157-vlan://untagged 2019-05-10 14:12:24,676 DEBUG [o.a.c.e.o.NetworkOrchestrator] (API-Job-Executor-36:ctx-839f6522 job-652 ctx-35fb4667) (logid:1ab7aa37) Allocating nic for vm VM[DomainRouter|r-85-VM] in network Ntwk[200|Public|1] with requested profile NicProfile[0-0-null-10.11.119.110-vlan://119 2019-05-10 14:12:24,699 DEBUG [o.a.c.e.o.NetworkOrchestrator] (API-Job-Executor-36:ctx-839f6522 job-652 ctx-35fb4667) (logid:1ab7aa37) Allocating nic for vm VM[DomainRouter|r-85-VM] in network Ntwk[200|Public|1] with requested profile NicProfile[0-0-null-10.11.119.110-vlan://119 2019-05-10 14:12:24,723 DEBUG [o.a.c.e.o.NetworkOrchestrator] (API-Job-Executor-36:ctx-839f6522 job-652 ctx-35fb4667) (logid:1ab7aa37) Allocating nic for vm VM[DomainRouter|r-85-VM] in network Ntwk[200|Public|1] with requested profile NicProfile[0-0-null-10.11.119.110-vlan://119 --- .../network/router/VpcNetworkHelperImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java b/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java index b4cf809726d5..4e49bd0e0a3f 100644 --- a/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java +++ b/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java @@ -154,14 +154,15 @@ public void reallocateRouterNetworks(final RouterDeploymentDefinition vpcRouterD publicVlans.add(publicIp.getVlanTag()); } } - if (publicNetwork != null) { - if (networks.get(publicNetwork) != null) { - @SuppressWarnings("unchecked") final List publicNicProfiles = (List)networks.get(publicNetwork); - publicNicProfiles.addAll(publicNics); - networks.put(publicNetwork, publicNicProfiles); - } else { - networks.put(publicNetwork, publicNics); - } + } + if (publicNetwork != null) { + if (networks.get(publicNetwork) != null) { + @SuppressWarnings("unchecked") + final List publicNicProfiles = (List)networks.get(publicNetwork); + publicNicProfiles.addAll(publicNics); + networks.put(publicNetwork, publicNicProfiles); + } else { + networks.put(publicNetwork, publicNics); } } @@ -187,4 +188,4 @@ public LinkedHashMap> configureDefaultNics(f return networks; } -} \ No newline at end of file +}