| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…all rules Since apache#12706 the Firewall service for public IPs of a VPC is provided by the VPC offering; the network offerings of the tiers do not list it. applyIpAssociations passes the services of the public IPs of a tier to VpcVirtualRouterElement.applyIps, which associates the IPs only when it can handle every one of these services on the tier. Once any public IP of the tier has a firewall rule, Firewall is in that set, canHandle(tier, Firewall) is false, and applyIps skips the association without an error: - port forwarding and load balancing rules on a new IP are applied, but the IP never reaches the router, also not on a network restart; - an IP whose last rule is removed stays configured on the router. Check the Firewall service on the VPC in that case, as applyFWRulesInVPC does. Other services and canHandle(network, service) are unchanged. Log when the IP association is skipped.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR fixes VPC tier public IP association logic so tiers can still associate IPs on the VPC virtual router when the Firewall service is provided by the VPC offering (not the tier network offering), and adds unit tests to cover the corrected behavior.
Changes:
| File | Description |
|---|---|
| server/src/main/java/com/cloud/network/element/VpcVirtualRouterElement.java | Adds canHandleIpService and updates applyIps to handle Firewall via VPC capability checks, plus debug logging when skipping association. |
| server/src/test/java/com/cloud/network/element/VpcVirtualRouterElementTest.java | Adds focused unit tests for applyIps behavior when Firewall is (or isn’t) provided by the VPC, and tests for canHandleIpService decision boundaries. |
Review effort: Lite
Sorry, something went wrong.
| return true; | ||
| } | ||
| if (Service.Firewall.equals(service) && network.getVpcId() != null) { | ||
| return canHandle(_vpcDao.findById(network.getVpcId()), service); |
There was a problem hiding this comment.
canHandle(Vpc, Service) already returns false for a null VPC (it is the first check in that
method), so there is no NullPointerException here: if the VPC cannot be found, the IP association is
skipped, as it was before this change, and the new debug line logs that. applyFWRulesInVPC goes
through the same method. I would leave it as it is.
Sorry, something went wrong.
| private Network mockVpcTier() { | ||
| final Network network = Mockito.mock(Network.class); | ||
| when(_networkMdl.getPhysicalNetworkId(network)).thenReturn(1L); | ||
| when(network.getId()).thenReturn(200L); | ||
| when(network.getVpcId()).thenReturn(100L); | ||
| when(_networkMdl.isProviderEnabledInPhysicalNetwork(1L, Network.Provider.VPCVirtualRouter.getName())).thenReturn(true); | ||
| return network; | ||
| } | ||
|
|
||
| private VpcVO mockVpc(final boolean vpcProvidesFirewall) { | ||
| final VpcVO vpc = Mockito.mock(VpcVO.class); | ||
| when(vpc.getId()).thenReturn(100L); | ||
| when(vpc.getZoneId()).thenReturn(1L); | ||
| when(_vpcDao.findById(100L)).thenReturn(vpc); | ||
| when(_networkMdl.isProviderEnabledInZone(1L, Network.Provider.VPCVirtualRouter.getName())).thenReturn(true); | ||
| when(_vpcMgr.isProviderSupportServiceInVpc(100L, Network.Service.Firewall, Network.Provider.VPCVirtualRouter)).thenReturn(vpcProvidesFirewall); | ||
| return vpc; | ||
| } |
There was a problem hiding this comment.
The new helpers use the same values as the existing testCanHandleFirewallUsesVpcCapability in this
class, which has 1L, 100L and 200L inline as well. I kept that style so the new tests read like
the existing one and the change stays small. Happy to switch both to named constants if reviewers
prefer.
Sorry, something went wrong.
|
@RosiKyu @nvazquez could this be considered for the 24.0 milestone? It fixes #14146 (moved to 25.0 earlier today) and #14669: in a VPC whose offering includes the Firewall service (#12706, new in 4.23.0.0), once a public IP of a tier has a firewall rule, further public IPs of that tier are no longer added to or removed from the virtual router. The change is limited to one method in VpcVirtualRouterElement and covered by unit tests. It also matters for the CKS fix in #14670, which adds firewall rules on the cluster IP. |
Sorry, something went wrong.
|
@adestis-mf , sure. Thank you for the clarification. Have mmoved #14146 back to 24.0 |
Sorry, something went wrong.
|
@RosiKyu a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
Sorry, something went wrong.
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20004 |
Sorry, something went wrong.
|
@RosiKyu a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
Sorry, something went wrong.
|
[SF] Trillian test result (tid-17565)
|
Sorry, something went wrong.
There was a problem hiding this comment.
code lgtm
Sorry, something went wrong.
There was a problem hiding this comment.
clgtm
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
This PR fixes adding and removing public IPs of a VPC tier on the VPC virtual router when the VPC
offering provides the Firewall service for public IPs (#12706).
IpAddressManagerImpl.applyIpAssociations passes VpcVirtualRouterElement.applyIps the union of
the services of the public IPs of a tier. Once a public IP of the tier has a firewall rule,
Firewall is part of that union. applyIps associates the IPs only when
canHandle(tier, service) is true for every service, and the tier's network offering does not
list the Firewall service, because #12706 puts it on the VPC offering. applyIps then skips the
association and returns true:
router, also not on a network restart;
applyIps now checks the Firewall service on the VPC when the tier does not provide it
(canHandle(Vpc, Firewall), the same check as in applyFWRulesInVPC). Other services and
canHandle(Network, Service) are unchanged, so testCanHandleFirewallUsesVpcCapability still
holds. A debug line is logged when the association is skipped, so the case is no longer silent.
What changes: in a VPC whose offering provides the Firewall service through the VPC virtual
router, public IPs of a tier are added to and removed from the router the same way as in a VPC
without the Firewall service. The IPs passed to the element are the same as before. IPs that have
only firewall rules and the source NAT IP of the VPC are not associated with a tier and are still
not passed. VPC offerings whose Firewall provider is not the VPC virtual router behave as before.
This targets main: #12706 is not in 4.22, and there is no 4.23 branch. The commit also
applies cleanly on top of the 4.23.0.0 tag.
Fixes: #14146
Fixes: #14669
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
New unit tests in VpcVirtualRouterElementTest:
the VPC does → the IPs are associated.
association, no router lookup.
consulted.
With the previous check (canHandle(network, service)) put back into applyIps,
testApplyIpsAssociatesTierIpsWhenTheVpcProvidesFirewall fails.
mvn -pl server -am test -Dtest=VpcVirtualRouterElementTest \ -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=falseVpcVirtualRouterElementTest: 8 tests, 0 failures. The tests in com.cloud.network.element,
com.cloud.network.router, com.cloud.network.vpc, com.cloud.network.lb,
com.cloud.network.firewall, IpAddressManager*Test and NetworkModel*Test also pass (352
tests, 0 failures, 4 skipped). Checkstyle reports no violations.
The behaviour without this change was reproduced on 4.23.0.0; steps and results are in #14146.
The patched build has not been run on a live system.
How did you try to break this feature and the system with this change?
I went through the cases in which the changed check decides differently:
so they are not passed to applyIps, as before;
has a firewall rule;
firewall rules;