summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYash Gupta <y.gupta@samsung.com>2018-08-27 17:43:27 +0900
committerDanil Golov <d.golov@samsung.com>2019-02-04 11:44:02 +0300
commitb0dfd35d76468986682a966c1fb609952fafc44f (patch)
tree9c059a9dec1848aa56816fd01e86e6a8ee227f70
parent721932dc4b030640c6615781f42cc5f44c9ba640 (diff)
Use same pool_driver for different pod_vif_drivers
New config option vif_pool_mapping is added and pools_vif_drivers is deprecated. The newer vif_pool_mapping is simply inverted mapping of pools_vif_drivers. Also, with the scoping ability added in cb2d308f84, independent drv_pool instances can be acquired from base driver manager. Earlier as a single instance of drv_pool was used by all pod_drivers. This meant only the pod_driver which was passed to drv_pool.set_vif_driver finally was used (for a given drv_pool). Please see release notes for further details. Related-Bug: 1747406 Change-Id: Id0137f6b1a78e7aa3e3d3de639a5e989f4fd408c Signed-off-by: Yash Gupta <y.gupta@samsung.com>
Notes
Notes (review): Code-Review+2: Luis Tomas Bolivar <ltomasbo@redhat.com> Code-Review+1: Danil Golov <d.golov@samsung.com> Code-Review+2: Berezovsky Irena <irenab.dev@gmail.com> Code-Review+2: Michał Dulko <mdulko@redhat.com> Workflow+1: Michał Dulko <mdulko@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 06 Feb 2019 01:04:48 +0000 Reviewed-on: https://review.openstack.org/596673 Project: openstack/kuryr-kubernetes Branch: refs/heads/master
-rw-r--r--doc/source/installation/ports-pool.rst20
-rw-r--r--kuryr_kubernetes/controller/drivers/vif_pool.py38
-rw-r--r--releasenotes/notes/reusable-pool-drivers-00e7fdc1f4738441.yaml31
3 files changed, 81 insertions, 8 deletions
diff --git a/doc/source/installation/ports-pool.rst b/doc/source/installation/ports-pool.rst
index 3fa434e..9a7b336 100644
--- a/doc/source/installation/ports-pool.rst
+++ b/doc/source/installation/ports-pool.rst
@@ -101,10 +101,10 @@ different VIF drivers (e.g., neutron and nested-vlan).
101 101
102This new multi pool driver is the default pool driver used even if a different 102This new multi pool driver is the default pool driver used even if a different
103vif_pool_driver is set at the config option. However if the configuration 103vif_pool_driver is set at the config option. However if the configuration
104about the mappings between the different pools and pod vif drivers is not 104about the mappings between the different pod vif and pools drivers is not
105provided at the pools_vif_drivers config option of vif_pool configuration 105provided at the vif_pool_mapping config option of vif_pool configuration
106section only one pool driver will be loaded -- using the standard 106section only one pool driver will be loaded -- using the standard
107vif_pool_driver and pod_vif_driver config options, i.e., using the one 107pod_vif_driver and vif_pool_driver config options, i.e., using the one
108selected at kuryr.conf options. 108selected at kuryr.conf options.
109 109
110To enable the option of having different pools depending on the node's pod 110To enable the option of having different pools depending on the node's pod
@@ -114,7 +114,7 @@ driver, e.g.:
114 .. code-block:: ini 114 .. code-block:: ini
115 115
116 [vif_pool] 116 [vif_pool]
117 pools_vif_drivers=nested:nested-vlan,neutron:neutron-vif 117 vif_pool_mapping=nested-vlan:nested,neutron-vif:neutron
118 118
119This will use a pool driver nested to handle the pods whose vif driver is 119This will use a pool driver nested to handle the pods whose vif driver is
120nested-vlan, and a pool driver neutron to handle the pods whose vif driver is 120nested-vlan, and a pool driver neutron to handle the pods whose vif driver is
@@ -123,5 +123,17 @@ will first read the node's annotation about pod_vif driver to use, e.g.,
123pod_vif: nested-vlan, and then use the corresponding pool driver -- which has 123pod_vif: nested-vlan, and then use the corresponding pool driver -- which has
124the right pod-vif driver set. 124the right pod-vif driver set.
125 125
126.. note::
127
128 Previously, `pools_vif_drivers` configuration option provided similar
129 functionality, but is now deprecated and not recommended.
130 It stored a mapping from pool_driver => pod_vif_driver instead, disallowing
131 the use of a single pool driver as keys for multiple pod_vif_drivers.
132
133 .. code-block:: ini
134
135 [vif_pool]
136 pools_vif_drivers=nested:nested-vlan,neutron:neutron-vif
137
126Note that if no annotation is set on a node, the default pod_vif_driver is 138Note that if no annotation is set on a node, the default pod_vif_driver is
127used. 139used.
diff --git a/kuryr_kubernetes/controller/drivers/vif_pool.py b/kuryr_kubernetes/controller/drivers/vif_pool.py
index f6f54d7..63a910b 100644
--- a/kuryr_kubernetes/controller/drivers/vif_pool.py
+++ b/kuryr_kubernetes/controller/drivers/vif_pool.py
@@ -26,6 +26,7 @@ from oslo_cache import core as cache
26from oslo_concurrency import lockutils 26from oslo_concurrency import lockutils
27from oslo_config import cfg as oslo_cfg 27from oslo_config import cfg as oslo_cfg
28from oslo_log import log as logging 28from oslo_log import log as logging
29from oslo_log import versionutils
29from oslo_serialization import jsonutils 30from oslo_serialization import jsonutils
30 31
31from kuryr_kubernetes import clients 32from kuryr_kubernetes import clients
@@ -61,6 +62,17 @@ vif_pool_driver_opts = [
61 "used. If not set, it will take them from the " 62 "used. If not set, it will take them from the "
62 "kubernetes driver options for pool and pod " 63 "kubernetes driver options for pool and pod "
63 "drivers respectively"), 64 "drivers respectively"),
65 default={}, deprecated_for_removal=True,
66 deprecated_since="Stein",
67 deprecated_reason=_(
68 "Mapping from pool->vif does not allow different "
69 "vifs to use the same pool driver. "
70 "Use vif_pool_mapping instead.")),
71 oslo_cfg.DictOpt('vif_pool_mapping',
72 help=_("Dict with the pod driver and the corresponding "
73 "pool driver to be used. If not set, it will take "
74 "them from the kubernetes driver options for pool "
75 "and pod drivers respectively"),
64 default={}), 76 default={}),
65] 77]
66 78
@@ -775,15 +787,16 @@ class MultiVIFPool(base.VIFPoolDriver):
775 787
776 def set_vif_driver(self): 788 def set_vif_driver(self):
777 self._vif_drvs = {} 789 self._vif_drvs = {}
778 pools_vif_drivers = oslo_cfg.CONF.vif_pool.pools_vif_drivers 790 vif_pool_mapping = self._get_vif_pool_mapping()
779 if not pools_vif_drivers: 791
792 if not vif_pool_mapping:
780 pod_vif = oslo_cfg.CONF.kubernetes.pod_vif_driver 793 pod_vif = oslo_cfg.CONF.kubernetes.pod_vif_driver
781 drv_vif = base.PodVIFDriver.get_instance() 794 drv_vif = base.PodVIFDriver.get_instance()
782 drv_pool = base.VIFPoolDriver.get_instance() 795 drv_pool = base.VIFPoolDriver.get_instance()
783 drv_pool.set_vif_driver(drv_vif) 796 drv_pool.set_vif_driver(drv_vif)
784 self._vif_drvs[pod_vif] = drv_pool 797 self._vif_drvs[pod_vif] = drv_pool
785 return 798 return
786 for pool_driver, pod_driver in pools_vif_drivers.items(): 799 for pod_driver, pool_driver in vif_pool_mapping.items():
787 if not utils.check_suitable_multi_pool_driver_opt(pool_driver, 800 if not utils.check_suitable_multi_pool_driver_opt(pool_driver,
788 pod_driver): 801 pod_driver):
789 LOG.error("The pool and pod driver selected are not " 802 LOG.error("The pool and pod driver selected are not "
@@ -792,7 +805,7 @@ class MultiVIFPool(base.VIFPoolDriver):
792 drv_vif = base.PodVIFDriver.get_instance( 805 drv_vif = base.PodVIFDriver.get_instance(
793 specific_driver=pod_driver) 806 specific_driver=pod_driver)
794 drv_pool = base.VIFPoolDriver.get_instance( 807 drv_pool = base.VIFPoolDriver.get_instance(
795 specific_driver=pool_driver) 808 specific_driver=pool_driver, scope='for:{}'.format(pod_driver))
796 drv_pool.set_vif_driver(drv_vif) 809 drv_pool.set_vif_driver(drv_vif)
797 self._vif_drvs[pod_driver] = drv_pool 810 self._vif_drvs[pod_driver] = drv_pool
798 811
@@ -839,3 +852,20 @@ class MultiVIFPool(base.VIFPoolDriver):
839 def _get_vif_drv_alias(self, vif): 852 def _get_vif_drv_alias(self, vif):
840 vif_type_name = type(vif).__name__ 853 vif_type_name = type(vif).__name__
841 return VIF_TYPE_TO_DRIVER_MAPPING[vif_type_name] 854 return VIF_TYPE_TO_DRIVER_MAPPING[vif_type_name]
855
856 def _get_vif_pool_mapping(self):
857 vif_pool_mapping = oslo_cfg.CONF.vif_pool.vif_pool_mapping
858
859 if not vif_pool_mapping:
860 pools_vif_drivers = oslo_cfg.CONF.vif_pool.pools_vif_drivers
861
862 if pools_vif_drivers:
863 msg = ("Config option vif_pool.pools_vif_drivers is "
864 "deprecated in favour of vif_pool.vif_pool_mapping, "
865 "and will be removed in a future release")
866 versionutils.report_deprecated_feature(LOG, msg)
867
868 for pool_driver, pod_driver in pools_vif_drivers.items():
869 vif_pool_mapping[pod_driver] = pool_driver
870
871 return vif_pool_mapping
diff --git a/releasenotes/notes/reusable-pool-drivers-00e7fdc1f4738441.yaml b/releasenotes/notes/reusable-pool-drivers-00e7fdc1f4738441.yaml
new file mode 100644
index 0000000..c440c80
--- /dev/null
+++ b/releasenotes/notes/reusable-pool-drivers-00e7fdc1f4738441.yaml
@@ -0,0 +1,31 @@
1---
2features:
3 - |
4 It is now possible to use same pool_driver for different pod_vif_drivers
5 when using MultiVIFPool driver.
6
7 A new config option `vif_pool.vif_pool_mapping` is introduced which is a
8 dict/mapping from pod_vif_driver => pool_driver. So different
9 pod_vif_drivers can be configured to use the same pool_driver.
10
11 .. code-block:: ini
12
13 [vif_pool]
14 vif_pool_mapping=nested-vlan:nested,neutron-vif:neutron
15
16 Earlier each instance of a pool_driver was mapped to a single
17 pod_driver, thus requiring a unique pool_driver for each pod_vif_driver.
18upgrade:
19 - |
20 If ``vif_pool.pools_vif_drivers`` config option is used, new config option
21 `vif_pool.vif_pool_mapping` should be populated with inverted mapping
22 from the present value of ``vif_pool.pools_vif_drivers``.
23deprecations:
24 - |
25 Configuration option ``vif_pool.pools_vif_drivers`` has been deprecated in
26 favour of ``vif_pool.vif_pool_mapping`` to allow reuse of pool_drivers for
27 different pod_vif_drivers.
28
29 If ``vif_pool_mapping`` is not configured, ``pools_vif_drivers`` will still
30 continue to work for now, but ``pools_vif_drivers`` will be completely
31 removed in a future release. \ No newline at end of file