futurewei-cloud / alcor

Alcor: Cloud native SDN platform powered by Kubernetes and Istio
MIT License
32 stars 33 forks source link

[Subnet Mgr] Subnet deletion needs to check if there is any port exists in the subnet #505

Closed cj-chung closed 3 years ago

cj-chung commented 3 years ago

Description: When a subnet is deleted, we need to check if there exist any gateway port or non-gateway port in the subnet. All ports need to be deleted before deleting the subnet. If there exists any non-gateway port, SM needs to raise a warning message and deny the deletion event.

Issue: In the current implementation, Subnet only has gateway port id, SM is able to ask PM to delete gateway port by port-id. However, subnet doesn't have normal port (port attached to VM) information. SM cannot query PM about related ports just by subnet-id.

Propose Solution:
Create an API in PM for SM to query its related non-gateway ports by subnet-id. Input: subnet_id Response: # of non-gateway ports (non-negative integer number)

xieus commented 3 years ago

We need to fix this issue when we get a chance.

xieus commented 3 years ago

We will need to change PM @chenpiaoping and SM @kevin-zhonghao at the same time.

chenpiaoping commented 3 years ago

Does the deletion of vpc also need to query whether subnet exists?

chenpiaoping commented 3 years ago

@xieus @cj-chung Since PM does not know which is gateway port and which is non-gateway port, and therefore does not know the number of non-gateway port, how about returning all the port id in subnet?

cj-chung commented 3 years ago

@chenpiaoping @kevin-zhonghao @xieus PM is able to know a port is either a normal port or a gw port. Subnet Manager will ask PM the number of normal ports under a subnet, if it returns zero, the deletion can go forward, otherwise a warning message will be displayed. So, just return the number of normal ports for the question subnet.