You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/10/17 00:30:30 UTC
[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #5580: VPC: support LB in multiple vpc tiers if LB provider is VpcVirtualRouter
DaanHoogland commented on a change in pull request #5580:
URL: https://github.com/apache/cloudstack/pull/5580#discussion_r729768154
##########
File path: server/src/main/java/com/cloud/network/rules/FirewallRules.java
##########
@@ -58,8 +59,11 @@ public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter
if (_purpose == Purpose.LoadBalancing) {
LoadBalancerDao loadBalancerDao = visitor.getVirtualNetworkApplianceFactory().getLoadBalancerDao();
- // for load balancer we have to resend all lb rules for the network
- final List<LoadBalancerVO> lbs = loadBalancerDao.listByNetworkIdAndScheme(_network.getId(), Scheme.Public);
+ // for load balancer we have to resend all lb rules for the network or vpc
+ final List<LoadBalancerVO> lbs = Optional.ofNullable(_network.getVpcId())
+ .map(x -> loadBalancerDao.listByVpcIdAndScheme(_network.getVpcId(), Scheme.Public))
+ .orElseGet(() -> loadBalancerDao.listByNetworkIdAndScheme(_network.getId(), Scheme.Public));
+
Review comment:
this is exactly the same code as in https://github.com/apache/cloudstack/pull/5580/files#diff-d2d1ae15d66bf44ddf906fe9ecf91b71f5ed830e55e0bd99b939fbb6b09e4a1f.
I think we should move this mapping to the `loadBalancerDao` and return the list in a single parametrised call.
##########
File path: server/src/main/java/com/cloud/network/rules/LoadBalancingRules.java
##########
@@ -50,8 +51,10 @@ public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter
_router = router;
LoadBalancerDao loadBalancerDao = visitor.getVirtualNetworkApplianceFactory().getLoadBalancerDao();
- // For load balancer we have to resend all lb rules for the network
- final List<LoadBalancerVO> lbs = loadBalancerDao.listByNetworkIdAndScheme(_network.getId(), Scheme.Public);
+ // For load balancer we have to resend all lb rules for the network or vpc
+ final List<LoadBalancerVO> lbs = Optional.ofNullable(_network.getVpcId())
+ .map(x -> loadBalancerDao.listByVpcIdAndScheme(_network.getVpcId(), Scheme.Public))
+ .orElseGet(() -> loadBalancerDao.listByNetworkIdAndScheme(_network.getId(), Scheme.Public));
Review comment:
repeated code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org