-
Notifications
You must be signed in to change notification settings - Fork 34
[Fundamental] Sub-level programming through Subnet and Route Mgr #468
[Fundamental] Sub-level programming through Subnet and Route Mgr #468
Conversation
services/route_manager/src/main/java/com/futurewei/alcor/route/controller/RouterController.java
Outdated
Show resolved
Hide resolved
...oute_manager/src/main/java/com/futurewei/alcor/route/controller/NeutronRouterController.java
Outdated
Show resolved
Hide resolved
services/route_manager/src/main/java/com/futurewei/alcor/route/controller/RouterController.java
Show resolved
Hide resolved
...es/route_manager/src/main/java/com/futurewei/alcor/route/service/Impl/RouterServiceImpl.java
Show resolved
Hide resolved
...net_manager/src/main/java/com/futurewei/alcor/subnet/service/implement/SubnetServiceImp.java
Outdated
Show resolved
Hide resolved
| public void deleteSubnetRoutingRuleInRM(String projectId, String subnetId) throws SubnetIdIsNull { | ||
|
|
||
| if (subnetId == null) { | ||
| throw new SubnetIdIsNull(); | ||
| } | ||
|
|
||
| String routeManagerServiceUrl = routeUrl + "project/" + projectId + "/subnets/" + subnetId + "/routetable"; | ||
| restTemplate.delete(routeManagerServiceUrl, ResponseId.class); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public void updateSubnetRoutingRuleInRM(String projectId, String subnetId, SubnetEntity subnetEntity) throws SubnetIdIsNull { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleteSubnetRoutingRuleInRM, updateSubnetRoutingRuleInRM, and createSubnetRoutingRuleInRM three functions are doing pretty similar task, should we consider to consolidate them into one function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually they should call different rest API and the same thing is to construct RouteTable in updateSubnetRoutingRuleInRM, createSubnetRoutingRuleInRM. We could put this process in one method, but I think sperate these three method is okay. What do you think?
...net_manager/src/main/java/com/futurewei/alcor/subnet/service/implement/SubnetServiceImp.java
Outdated
Show resolved
Hide resolved
...net_manager/src/main/java/com/futurewei/alcor/subnet/service/implement/SubnetServiceImp.java
Outdated
Show resolved
Hide resolved
...net_manager/src/main/java/com/futurewei/alcor/subnet/service/implement/SubnetServiceImp.java
Outdated
Show resolved
Hide resolved
|
|
||
| for (int i = 0 ; i < hostRoutes.size(); i ++) { | ||
| HostRoute hostRoute = hostRoutes.get(i); | ||
| String subnetDestination = hostRoute.getDestination(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it costs too much to iterate all routes for each UPDATE route?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HostRoute dont have its own repo, so I think we could do in this way, I think subnet dont have many hostRoutes, right?
| Iterator<HostRoute> iterator = hostRoutes.iterator(); | ||
| while (iterator.hasNext()) { | ||
| HostRoute hostRoute = iterator.next(); | ||
| String subnetDestination = hostRoute.getDestination(); | ||
| if (subnetDestination == null) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment above, can we lookup hostRoute by destination?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the response above
...e_manager/src/main/java/com/futurewei/alcor/route/service/Impl/NeutronRouterServiceImpl.java
Show resolved
Hide resolved
# Conflicts: # services/data_plane_manager/src/main/java/com/futurewei/alcor/dataplane/service/ovs/DataPlaneServiceImplNew.java
Codecov Report
@@ Coverage Diff @@
## master #468 +/- ##
============================================
- Coverage 36.59% 35.69% -0.90%
- Complexity 1162 1166 +4
============================================
Files 453 467 +14
Lines 10869 11311 +442
Branches 1393 1456 +63
============================================
+ Hits 3977 4037 +60
- Misses 6350 6721 +371
- Partials 542 553 +11
Continue to review full report at Codecov.
|
...e_manager/src/main/java/com/futurewei/alcor/route/service/Impl/NeutronRouterServiceImpl.java
Outdated
Show resolved
Hide resolved
web/src/main/java/com/futurewei/alcor/web/entity/route/RoutesToNeutronWebRequest.java
Outdated
Show resolved
Hide resolved
...oute_manager/src/main/java/com/futurewei/alcor/route/controller/NeutronRouterController.java
Outdated
Show resolved
Hide resolved
web/src/main/java/com/futurewei/alcor/web/entity/route/UpdateRoutingRuleResponse.java
Outdated
Show resolved
Hide resolved
...oute_manager/src/main/java/com/futurewei/alcor/route/controller/NeutronRouterController.java
Outdated
Show resolved
Hide resolved
...oute_manager/src/main/java/com/futurewei/alcor/route/controller/NeutronRouterController.java
Outdated
Show resolved
Hide resolved
...oute_manager/src/main/java/com/futurewei/alcor/route/controller/NeutronRouterController.java
Outdated
Show resolved
Hide resolved
services/route_manager/src/main/java/com/futurewei/alcor/route/config/ConstantsConfig.java
Outdated
Show resolved
Hide resolved
services/route_manager/src/main/java/com/futurewei/alcor/route/controller/RouterController.java
Outdated
Show resolved
Hide resolved
services/route_manager/src/main/java/com/futurewei/alcor/route/controller/RouterController.java
Show resolved
Hide resolved
services/route_manager/src/main/java/com/futurewei/alcor/route/controller/RouterController.java
Outdated
Show resolved
Hide resolved
services/route_manager/src/main/java/com/futurewei/alcor/route/controller/RouterController.java
Outdated
Show resolved
Hide resolved
...e_manager/src/main/java/com/futurewei/alcor/route/service/Impl/NeutronRouterServiceImpl.java
Outdated
Show resolved
Hide resolved
| routingRuleExtraInfo.setDestinationType(VpcRouteTarget.LOCAL); | ||
|
|
||
| if (route == null) { | ||
| internalRoutingRule.setId(route.getId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that possible for route == null, that's mean existing route doesn't exist?
If it's null, how can you getId() from a null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, route == null is possible I think. And the two lines of code here are indeed in reverse order
| if (newRouteRequest != null) { | ||
| internalRoutingRule.setDestination(newRouteRequest.getDestination()); | ||
| } else { | ||
| internalRoutingRule.setDestination(route.getDestination()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just set these properties based on the operation type?
if (operationType == CREATE), the routing rule's properties use new route's properties.
if (operationType == UPDATE), only nexthop use new route's property, others use existing route's properties.
if (operationType == DELETE), use existing route's properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it is same as the logic here, since we have to set RouteEntry route and NewRoutesRequest newRouteRequest in params
...e_manager/src/main/java/com/futurewei/alcor/route/service/Impl/NeutronRouterServiceImpl.java
Show resolved
Hide resolved
...e_manager/src/main/java/com/futurewei/alcor/route/service/Impl/NeutronRouterServiceImpl.java
Show resolved
Hide resolved
| for (String gatewayPortId : gatewayPorts) { | ||
| String portManagerServiceUrl = portUrl + "/project/" + projectid + "/ports/" + gatewayPortId; | ||
| PortWebJson portResponse = restTemplate.getForObject(portManagerServiceUrl, PortWebJson.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does PM has bulk create/query by a list of IP addresses?
If there is, we can just make an API call and do a batch process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, PM has bulk create/query API. But here we query PortEntity by port id, right?
...c/main/java/com/futurewei/alcor/subnet/service/implement/SubnetToPortManagerServiceImpl.java
Show resolved
Hide resolved
...c/main/java/com/futurewei/alcor/subnet/service/implement/SubnetToPortManagerServiceImpl.java
Show resolved
Hide resolved
web/src/main/java/com/futurewei/alcor/web/entity/route/InternalRouterConfiguration.java
Outdated
Show resolved
Hide resolved
xieus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| if (portEntity.isGatewayPort()) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comments.
| } | ||
|
|
||
| getSubnetAndRoute(context, new ArrayList<>(subnetIds)); | ||
| //getSubnetAndRoute(context, new ArrayList<>(subnetIds)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chenpiaoping Could you pls review this change? I raised a question on Slack channel regarding why we need to reevaluate subnet and route after allocating IP address.
xieus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR includes quite a few fundamental changes in Route Manager, Subnet Manager and Web Entities. The new features added by this PR get in an important piece of puzzle for Alcor and enable more comprehensive routing support. 👍
Thank you @kevin-zhonghao and @cj-chung
| // CompletableFuture<MacStateJson> macFuture = CompletableFuture.supplyAsync(() -> { | ||
| // try { | ||
| // return this.subnetService.allocateMacAddressForGatewayPort(projectId, vpcId, portId); | ||
| // } catch (Exception e) { | ||
| // throw new CompletionException(e); | ||
| // } | ||
| // }, ThreadPoolExecutorUtils.SELECT_POOL_EXECUTOR).handle((s, e) -> { | ||
| // macResponseAtomic.set(s); | ||
| // if (e != null) { | ||
| // throw new CompletionException(e); | ||
| // } | ||
| // return s; | ||
| // }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove and cleanup the commented codes. @kevin-zhonghao
| // MacState macState = macResponse.getMacState(); | ||
| // if (macState != null) { | ||
| // inSubnetEntity.setGatewayMacAddress(macState.getMacAddress()); | ||
| // } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
| #####Microservice url configuration###### | ||
| microservices.subnet.service.url=http://localhost:9002 | ||
| microservices.vpc.service.url=http://localhost:9001 | ||
| microservices.dpm.service.url=http://localhost:9010 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the new configurations in RM and SM, don't forget to add them in K8s yaml file :-)
|
Item 4 resolves Issue #407. |
The implementation of Sub-level programming mainly includes the following features:
Test scenarios: