Merge "Remove port from trunk on _cleanup_leftover_ports"
This commit is contained in:
commit
deb055190f
|
@ -111,33 +111,7 @@ class NamespacePodSubnetDriver(default_subnet.DefaultPodSubnetDriver):
|
|||
if leftover_port.device_owner not in ['', 'trunk:subport',
|
||||
kl_const.DEVICE_OWNER]:
|
||||
continue
|
||||
try:
|
||||
# NOTE(gryf): there is unlikely, that we get an exception
|
||||
# like PortNotFound or something, since openstacksdk
|
||||
# doesn't raise an exception if port doesn't exists nor
|
||||
# return any information.
|
||||
os_net.delete_port(leftover_port.id)
|
||||
except os_exc.SDKException as e:
|
||||
if "currently a subport for trunk" in str(e):
|
||||
if leftover_port.status == "DOWN":
|
||||
LOG.warning("Port %s is in DOWN status but still "
|
||||
"associated to a trunk. This should "
|
||||
"not happen. Trying to delete it from "
|
||||
"the trunk.", leftover_port.id)
|
||||
# Get the trunk_id from the error message
|
||||
trunk_id = (
|
||||
str(e).split('trunk')[1].split('.')[0].strip())
|
||||
try:
|
||||
os_net.delete_trunk_subports(
|
||||
trunk_id, [{'port_id': leftover_port.id}])
|
||||
except os_exc.NotFoundException:
|
||||
LOG.debug("Port %s already removed from trunk %s",
|
||||
leftover_port['id'], trunk_id)
|
||||
else:
|
||||
LOG.exception("Unexpected error deleting leftover "
|
||||
"port %s. Skiping it and continue with "
|
||||
"the other rest.", leftover_port.id)
|
||||
|
||||
c_utils.delete_port(leftover_port)
|
||||
raise exceptions.ResourceNotReady(net_id)
|
||||
except os_exc.SDKException:
|
||||
LOG.exception("Error deleting network %s.", net_id)
|
||||
|
|
|
@ -680,3 +680,44 @@ def is_network_policy_enabled():
|
|||
enabled_handlers = CONF.kubernetes.enabled_handlers
|
||||
svc_sg_driver = CONF.kubernetes.service_security_groups_driver
|
||||
return 'policy' in enabled_handlers and svc_sg_driver == 'policy'
|
||||
|
||||
|
||||
def delete_port(leftover_port):
|
||||
os_net = clients.get_network_client()
|
||||
|
||||
try:
|
||||
# NOTE(gryf): there is unlikely, that we get an exception
|
||||
# like PortNotFound or something, since openstacksdk
|
||||
# doesn't raise an exception if port doesn't exists nor
|
||||
# return any information.
|
||||
os_net.delete_port(leftover_port.id)
|
||||
except os_exc.SDKException as e:
|
||||
if "currently a subport for trunk" in str(e):
|
||||
if leftover_port.status == "DOWN":
|
||||
LOG.warning("Port %s is in DOWN status but still "
|
||||
"associated to a trunk. This should "
|
||||
"not happen. Trying to delete it from "
|
||||
"the trunk.", leftover_port.id)
|
||||
|
||||
# Get the trunk_id from the error message
|
||||
trunk_id = (
|
||||
str(e).split('trunk')[1].split('.')[0].strip())
|
||||
try:
|
||||
os_net.delete_trunk_subports(
|
||||
trunk_id, [{'port_id': leftover_port.id}])
|
||||
except os_exc.ResourceNotFound:
|
||||
LOG.debug(
|
||||
"Port %s already removed from trunk %s",
|
||||
leftover_port.id, trunk_id)
|
||||
try:
|
||||
os_net.delete_port(leftover_port.id)
|
||||
except os_exc.SDKException:
|
||||
LOG.exception("Unexpected error deleting "
|
||||
"leftover port %s. Skipping it "
|
||||
"and continue with the other "
|
||||
"rest.", leftover_port.id)
|
||||
else:
|
||||
LOG.exception("Unexpected error deleting leftover "
|
||||
"port %s. Skipping it and "
|
||||
"continue with the other "
|
||||
"rest.", leftover_port.id)
|
||||
|
|
|
@ -477,7 +477,7 @@ class BaseVIFPool(base.VIFPoolDriver, metaclass=abc.ABCMeta):
|
|||
else:
|
||||
for port in existing_ports:
|
||||
if not port.binding_host_id:
|
||||
os_net.delete_port(port.id)
|
||||
c_utils.delete_port(port)
|
||||
|
||||
def _cleanup_removed_nodes(self):
|
||||
"""Remove ports associated to removed nodes."""
|
||||
|
|
Loading…
Reference in New Issue