Skip to content

Commit

Permalink
Merge pull request #290 from kuryr-bot/rebase-2020-06-26
Browse files Browse the repository at this point in the history
Rebase openshift/kuryr-kubernetes from https://opendev.org/openstack/kuryr-kubernetes
  • Loading branch information
openshift-merge-robot committed Jun 26, 2020
2 parents 03413eb + 5115c29 commit cef2a95
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 26 deletions.
3 changes: 1 addition & 2 deletions kuryr_kubernetes/controller/drivers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def release_vifs(self, pods, vifs, project_id=None, security_groups=None):
raise NotImplementedError()

@abc.abstractmethod
def activate_vif(self, pod, vif):
def activate_vif(self, vif):
"""Updates VIF to become active.
Implementing drivers should update the specified `vif` object's
Expand All @@ -403,7 +403,6 @@ def activate_vif(self, pod, vif):
This method may be called before, after or while the VIF is being
plugged by the CNI plugin.
:param pod: dict containing Kubernetes Pod object
:param vif: VIF object as returned by `PodVIFDriver.request_vif`
"""
raise NotImplementedError()
Expand Down
2 changes: 1 addition & 1 deletion kuryr_kubernetes/controller/drivers/nested_dpdk_vif.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def release_vif(self, pod, vif, project_id=None, security_groups=None):
vif.id, vm_id)
raise

def activate_vif(self, pod, vif):
def activate_vif(self, vif):
# NOTE(danil): new virtual interface was created in nova instance
# during request_vif call, thus if it was not created successfully
# an exception o_exc.SDKException would be throwed. During binding
Expand Down
2 changes: 1 addition & 1 deletion kuryr_kubernetes/controller/drivers/nested_macvlan_vif.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def release_vif(self, pod, vif, project_id=None, security_groups=None):
LOG.warning("Unable to release port %s as it no longer exists.",
vif.id)

def activate_vif(self, pod, vif):
def activate_vif(self, vif):
# NOTE(mchiappe): there is no way to get feedback on the actual
# interface creation or activation as no plugging can happen for this
# interface type. However the status of the port is not relevant as
Expand Down
2 changes: 1 addition & 1 deletion kuryr_kubernetes/controller/drivers/neutron_vif.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def request_vifs(self, pod, project_id, subnets, security_groups,
def release_vif(self, pod, vif, project_id=None, security_groups=None):
clients.get_network_client().delete_port(vif.id)

def activate_vif(self, pod, vif):
def activate_vif(self, vif):
if vif.active:
return

Expand Down
2 changes: 1 addition & 1 deletion kuryr_kubernetes/controller/drivers/sriov.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def request_vif(self, pod, project_id, subnets, security_groups):
self._reduce_remaining_sriov_vfs(pod, physnet)
return vif

def activate_vif(self, pod, vif):
def activate_vif(self, vif):
vif.active = True

def _get_physnet_subnet_mapping(self):
Expand Down
12 changes: 6 additions & 6 deletions kuryr_kubernetes/controller/drivers/vif_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def request_vif(self, pod, project_id, subnets, security_groups):
def release_vif(self, pod, vif, *argv):
self._drv_vif.release_vif(pod, vif, *argv)

def activate_vif(self, pod, vif):
self._drv_vif.activate_vif(pod, vif)
def activate_vif(self, vif):
self._drv_vif.activate_vif(vif)

def update_vif_sgs(self, pod, sgs):
self._drv_vif.update_vif_sgs(pod, sgs)
Expand Down Expand Up @@ -166,8 +166,8 @@ def __init__(self):
def set_vif_driver(self, driver):
self._drv_vif = driver

def activate_vif(self, pod, vif):
self._drv_vif.activate_vif(pod, vif)
def activate_vif(self, vif):
self._drv_vif.activate_vif(vif)

def update_vif_sgs(self, pod, sgs):
self._drv_vif.update_vif_sgs(pod, sgs)
Expand Down Expand Up @@ -1068,9 +1068,9 @@ def release_vif(self, pod, vif, *argv):
vif_drv_alias = self._get_vif_drv_alias(vif)
self._vif_drvs[vif_drv_alias].release_vif(pod, vif, *argv)

def activate_vif(self, pod, vif):
def activate_vif(self, vif):
vif_drv_alias = self._get_vif_drv_alias(vif)
self._vif_drvs[vif_drv_alias].activate_vif(pod, vif)
self._vif_drvs[vif_drv_alias].activate_vif(vif)

def update_vif_sgs(self, pod, sgs):
pod_vif_type = self._get_pod_vif_type(pod)
Expand Down
2 changes: 1 addition & 1 deletion kuryr_kubernetes/controller/handlers/vif.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def on_present(self, pod):
driver_utils.update_port_pci_info(pod, vif)
if not vif.active:
try:
self._drv_vif_pool.activate_vif(pod, vif)
self._drv_vif_pool.activate_vif(vif)
changed = True
except os_exc.ResourceNotFound:
LOG.debug("Port not found, possibly already "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,9 @@ def test_release_detach_failed(self):
def test_activate_vif(self, active_value):
cls = nested_dpdk_vif.NestedDpdkPodVIFDriver
m_driver = mock.Mock(spec=cls)
pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = active_value

cls.activate_vif(m_driver, pod, vif)
cls.activate_vif(m_driver, vif)

self.assertEqual(vif.active, True)
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,10 @@ def test_release_vif_delete_failed(self):
def test_activate_vif(self, active_value):
cls = nested_macvlan_vif.NestedMacvlanPodVIFDriver
m_driver = mock.Mock(spec=cls)
pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = active_value

cls.activate_vif(m_driver, pod, vif)
cls.activate_vif(m_driver, vif)

self.assertEqual(vif.active, True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,14 @@ def test_activate_vif(self):
m_driver = mock.Mock(spec=cls)
os_net = self.useFixture(k_fix.MockNetworkClient()).client

pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = False
port = mock.MagicMock()

port.__getitem__.return_value = kl_const.PORT_STATUS_ACTIVE
os_net.get_port.return_value = port

cls.activate_vif(m_driver, pod, vif)
cls.activate_vif(m_driver, vif)

os_net.get_port.assert_called_once_with(vif.id)
self.assertTrue(vif.active)
Expand All @@ -202,11 +201,10 @@ def test_activate_vif_active(self):
m_driver = mock.Mock(spec=cls)
os_net = self.useFixture(k_fix.MockNetworkClient()).client

pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = True

cls.activate_vif(m_driver, pod, vif)
cls.activate_vif(m_driver, vif)

os_net.get_port.assert_not_called()

Expand All @@ -215,7 +213,6 @@ def test_activate_vif_not_ready(self):
m_driver = mock.Mock(spec=cls)
os_net = self.useFixture(k_fix.MockNetworkClient()).client

pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = False
port = mock.MagicMock()
Expand All @@ -224,7 +221,7 @@ def test_activate_vif_not_ready(self):
os_net.get_port.return_value = port

self.assertRaises(k_exc.ResourceNotReady, cls.activate_vif,
m_driver, pod, vif)
m_driver, vif)

def _test_get_port_request(self, m_to_fips, security_groups,
m_get_device_id, m_get_port_name, m_get_host_id,
Expand Down
3 changes: 1 addition & 2 deletions kuryr_kubernetes/tests/unit/controller/drivers/test_sriov.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ def test_activate_vif(self):
cls = drvs.SriovVIFDriver
m_driver = mock.Mock(spec=cls)

pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = False

cls.activate_vif(m_driver, pod, vif)
cls.activate_vif(m_driver, vif)
self.assertEqual(True, vif.active)

@mock.patch('kuryr_kubernetes.os_vif_util.osvif_to_neutron_fixed_ips')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def test_on_present_activate(self, m_get_pod_state, m_host_network,

m_get_pod_state.assert_called_once_with(self._pod)
m_update_pci.assert_called_once_with(self._pod, self._vif)
self._activate_vif.assert_called_once_with(self._pod, self._vif)
self._activate_vif.assert_called_once_with(self._vif)
self._set_pod_state.assert_called_once_with(self._pod, self._state)
self._request_vif.assert_not_called()
self._request_additional_vifs.assert_not_called()
Expand Down

0 comments on commit cef2a95

Please sign in to comment.