-
Notifications
You must be signed in to change notification settings - Fork 34
[RM] Separate getOrCreateVPCRouter into GET and POST two APIs #655
Conversation
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
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
Show resolved
Hide resolved
services/route_manager/src/main/java/com/futurewei/alcor/route/controller/RouterController.java
Show resolved
Hide resolved
| public RouteTablesWebJson getVpcRouteTables(@PathVariable String projectid, @PathVariable String vpcid) throws Exception { | ||
|
|
||
| List<RouteTable> routetables = new ArrayList<>(); | ||
| List<RouteTable> routetables = 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.
@DavidLiu506 If you set this as null and this function cannot find vpcroutetables, line 299 in this code will get NPE (null point exception).
Also, please uncomment line 309 in this file. We need to send internalRouterInfo to DPM.
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.
line send internalRouterInfo to DPM uncomment.
updateVpcRouteTable in RouterController will not get NPE because updateVpcRouteTable in RouterServiceImpl already handle it.
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.
@DavidLiu506 I didn't see you have handled if this function return null in updateVpcRouteTable:
List<RouteTable> vpcRouteTables = router.getVpcRouteTables();
for (RouteTable vpcRouteTable : vpcRouteTables) {
String routeTableType = vpcRouteTable.getRouteTableType();
if (RouteTableType.VPC.getRouteTableType().equals(routeTableType)) {
return vpcRouteTable;
}
}
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.
Sorry, you are right. Fixed.
| value = {"/project/{projectid}/subnets/{subnetid}/routetable"}) | ||
| @DurationStatistics | ||
| public RouteTableWebJson createNeutronSubnetRouteTable(@PathVariable String projectid, @PathVariable String subnetid, @RequestBody RouteTableWebJson resource) throws Exception { | ||
| public RouteTableWebJson createSubnetRouteTable(@PathVariable String projectid, @PathVariable String subnetid, @RequestBody RouteTableWebJson resource) throws Exception { |
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.
@kevin-zhonghao Did you also modify this function? Is that ok to rename this function?
@DavidLiu506 Please check PR#657
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.
Merged
...es/route_manager/src/main/java/com/futurewei/alcor/route/service/Impl/RouterServiceImpl.java
Show resolved
Hide resolved
|
|
||
| @Override | ||
| public RouteTable getSubnetRouteTable(String projectId, String subnetId) throws CacheException, OwnMultipleSubnetRouteTablesException, DatabasePersistenceException, ResourceNotFoundException, ResourcePersistenceException, CanNotFindSubnet, OwnMultipleVpcRouterException, CanNotFindVpc { | ||
| public RouteTable getSubnetRouteTable(String projectId, String subnetId) throws CacheException, CanNotFindRouteTableByOwner, OwnMultipleSubnetRouteTablesException { |
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.
@kevin-zhonghao Did you also update this function? Please confirm!
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.
Merged
...es/route_manager/src/main/java/com/futurewei/alcor/route/service/Impl/RouterServiceImpl.java
Show resolved
Hide resolved
| value = {"/project/{projectid}/subnets/{subnetid}/routetable"}) | ||
| @DurationStatistics | ||
| public RouteTableWebJson getOrCreateSubnetRouteTable(@PathVariable String projectid, @PathVariable String subnetid) throws Exception { | ||
| public RouteTableWebJson getSubnetRouteTable(@PathVariable String projectid, @PathVariable String subnetid) throws Exception { |
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.
@kevin-zhonghao Please check if you also modify this function in your PR.
@DavidLiu506 Please check PR#657
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.
Merged
| if (routetables == null) | ||
| { | ||
| throw new RouterUnavailable(); | ||
| } | ||
|
|
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.
@DavidLiu506 Is this a RouterUnavailable or RouteTableUnavailable?
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.
Thanks!
| routes.add(defaultRoute); | ||
|
|
||
| routeTable = this.routerService.createNeutronSubnetRouteTable(projectid, subnetid, resource, routes); | ||
| routeTable = this.routerService.createSubnetRouteTable(projectid, subnetid, resource, routes); |
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.
@DavidLiu506 We need to remove line#454~#456 defaultRoute setting.
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.
Removed.
cj-chung
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
Router controller:
getOrCreateVPCRouter
-> rename as 'getVPCRoutercreate', and delete 'create' operation related part
-> Add a new API 'createVPCRouter'
getOrCreateSubnetRouteTable
-> rename as 'getSubnetRouteTable', and delete 'create' operation related part
createNeutronSubnetRouteTable
-> rename as 'createSubnetRouteTable'
getOrCreateVpcRouteTable
-> rename as 'getVpcRouteTable', and delete 'create' operation related part
-> Add a new API 'createVpcRouteTable'