[subnet] Cannot delete a subnet without a gateway port and routing table
Issue: Cannot delete a subnet without a gateway port It will return
{
"timestamp": "2021-06-23T19:24:44.531+0000",
"status": 500,
"error": "Internal Server Error",
"message": "404 : [{\"timestamp\":\"2021-06-23T19:24:44.493+0000\",\"status\":404,\"error\":\"Not Found\",\"message\":\"Port not found\",\"path\":\"/project/3dda2801-d675-4688-a63f-dcda8d327f50/ports/145e37e1-e9b1-4f92-b6f6-6a62c636c4e8\"}]",
"path": "/project/3dda2801-d675-4688-a63f-dcda8d327f50/subnets/8182a4d4-ffff-4ece-b3f0-8d36e3d88001"
}
Suggestion: A subnet without gateway port should be able to be deleted.
Temporary Solution:
For temporary solution in Subnet Manager, we can modify codes in SubnetController.java line 543 to:
...
import org.springframework.web.client.HttpClientErrorException;
...
// TODO: delete gateway port in port manager. Temporary solution, need PM fix issue
GatewayPortDetail gatewayPortDetail = subnetEntity.getGatewayPortDetail();
if (gatewayPortDetail != null) {
try {
this.subnetToPortManagerService.deleteGatewayPort(projectId, gatewayPortDetail.getGatewayPortId());
} catch (HttpClientErrorException.NotFound e) {
logger.warn(e.getMessage());
}
}
For the formal solution, we still need to modify PM's code. Check if the deleted port is subnet's gateway port. If it is a gateway port, PM needs to notify SM to update subnet's GatewayPortDetail. This is same as gateway port's update.
Subnet's routing table also has similar issue. We need to try and catch this.subnetService.deleteSubnetRoutingRuleInRM(projectId, subnetId); too:
// delete subnet routing rule in route manager
try {
this.subnetService.deleteSubnetRoutingRuleInRM(projectId, subnetId);
} catch (HttpClientErrorException.NotFound e) {
logger.warn(e.getMessage());
}