Ensure tags are used to recover/clean ports
This patch ensures that, if tags are used, only the ports with the given tags are considered for recovering/cleanup Change-Id: I7953bc1122a77e5ed5f0cfd21ca81b1ac2d731a1
This commit is contained in:
parent
1e11b11d50
commit
046e4b31c7
|
@ -348,7 +348,11 @@ class BaseVIFPool(base.VIFPoolDriver):
|
||||||
subports = {}
|
subports = {}
|
||||||
subnets = {}
|
subnets = {}
|
||||||
|
|
||||||
all_active_ports = self._get_ports_by_attrs(status='ACTIVE')
|
attrs = {'status': 'ACTIVE'}
|
||||||
|
tags = config.CONF.neutron_defaults.resource_tags
|
||||||
|
if tags:
|
||||||
|
attrs['tags'] = tags
|
||||||
|
all_active_ports = self._get_ports_by_attrs(**attrs)
|
||||||
in_use_ports = self._get_in_use_ports()
|
in_use_ports = self._get_in_use_ports()
|
||||||
|
|
||||||
for port in all_active_ports:
|
for port in all_active_ports:
|
||||||
|
@ -462,8 +466,11 @@ class NeutronVIFPool(BaseVIFPool):
|
||||||
neutron = clients.get_neutron_client()
|
neutron = clients.get_neutron_client()
|
||||||
sg_current = {}
|
sg_current = {}
|
||||||
if not config.CONF.kubernetes.port_debug:
|
if not config.CONF.kubernetes.port_debug:
|
||||||
kuryr_ports = self._get_ports_by_attrs(
|
attrs = {'device_owner': kl_const.DEVICE_OWNER}
|
||||||
device_owner=kl_const.DEVICE_OWNER)
|
tags = config.CONF.neutron_defaults.resource_tags
|
||||||
|
if tags:
|
||||||
|
attrs['tags'] = tags
|
||||||
|
kuryr_ports = self._get_ports_by_attrs(**attrs)
|
||||||
for port in kuryr_ports:
|
for port in kuryr_ports:
|
||||||
if port['id'] in self._recyclable_ports:
|
if port['id'] in self._recyclable_ports:
|
||||||
sg_current[port['id']] = tuple(sorted(
|
sg_current[port['id']] = tuple(sorted(
|
||||||
|
@ -509,13 +516,16 @@ class NeutronVIFPool(BaseVIFPool):
|
||||||
LOG.debug('Port already recycled: %s', port_id)
|
LOG.debug('Port already recycled: %s', port_id)
|
||||||
|
|
||||||
def _recover_precreated_ports(self):
|
def _recover_precreated_ports(self):
|
||||||
|
attrs = {'device_owner': kl_const.DEVICE_OWNER}
|
||||||
|
tags = config.CONF.neutron_defaults.resource_tags
|
||||||
|
if tags:
|
||||||
|
attrs['tags'] = tags
|
||||||
|
|
||||||
if config.CONF.kubernetes.port_debug:
|
if config.CONF.kubernetes.port_debug:
|
||||||
available_ports = self._get_ports_by_attrs(
|
attrs['name'] = constants.KURYR_PORT_NAME
|
||||||
name=constants.KURYR_PORT_NAME, device_owner=[
|
available_ports = self._get_ports_by_attrs(**attrs)
|
||||||
kl_const.DEVICE_OWNER])
|
|
||||||
else:
|
else:
|
||||||
kuryr_ports = self._get_ports_by_attrs(
|
kuryr_ports = self._get_ports_by_attrs(**attrs)
|
||||||
device_owner=kl_const.DEVICE_OWNER)
|
|
||||||
in_use_ports = self._get_in_use_ports()
|
in_use_ports = self._get_in_use_ports()
|
||||||
available_ports = [port for port in kuryr_ports
|
available_ports = [port for port in kuryr_ports
|
||||||
if port['id'] not in in_use_ports]
|
if port['id'] not in in_use_ports]
|
||||||
|
@ -683,8 +693,11 @@ class NestedVIFPool(BaseVIFPool):
|
||||||
neutron = clients.get_neutron_client()
|
neutron = clients.get_neutron_client()
|
||||||
sg_current = {}
|
sg_current = {}
|
||||||
if not config.CONF.kubernetes.port_debug:
|
if not config.CONF.kubernetes.port_debug:
|
||||||
kuryr_subports = self._get_ports_by_attrs(
|
attrs = {'device_owner': ['trunk:subport', kl_const.DEVICE_OWNER]}
|
||||||
device_owner=['trunk:subport', kl_const.DEVICE_OWNER])
|
tags = config.CONF.neutron_defaults.resource_tags
|
||||||
|
if tags:
|
||||||
|
attrs['tags'] = tags
|
||||||
|
kuryr_subports = self._get_ports_by_attrs(**attrs)
|
||||||
for subport in kuryr_subports:
|
for subport in kuryr_subports:
|
||||||
if subport['id'] in self._recyclable_ports:
|
if subport['id'] in self._recyclable_ports:
|
||||||
sg_current[subport['id']] = tuple(sorted(
|
sg_current[subport['id']] = tuple(sorted(
|
||||||
|
|
Loading…
Reference in New Issue