Browse Source

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>
tags/1.0.0
Yash Gupta 10 months ago
parent
commit
b0dfd35d76

+ 16
- 4
doc/source/installation/ports-pool.rst View File

@@ -101,10 +101,10 @@ different VIF drivers (e.g., neutron and nested-vlan).
101 101
 
102 102
 This new multi pool driver is the default pool driver used even if a different
103 103
 vif_pool_driver is set at the config option. However if the configuration
104
-about the mappings between the different pools and pod vif drivers is not
105
-provided at the pools_vif_drivers config option of vif_pool configuration
104
+about the mappings between the different pod vif and pools drivers is not
105
+provided at the vif_pool_mapping config option of vif_pool configuration
106 106
 section only one pool driver will be loaded -- using the standard
107
-vif_pool_driver and pod_vif_driver config options, i.e., using the one
107
+pod_vif_driver and vif_pool_driver  config options, i.e., using the one
108 108
 selected at kuryr.conf options.
109 109
 
110 110
 To enable the option of having different pools depending on the node's pod
@@ -114,7 +114,7 @@ driver, e.g.:
114 114
     .. code-block:: ini
115 115
 
116 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
 
119 119
 This will use a pool driver nested to handle the pods whose vif driver is
120 120
 nested-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.,
123 123
 pod_vif: nested-vlan, and then use the corresponding pool driver -- which has
124 124
 the 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
+
126 138
 Note that if no annotation is set on a node, the default pod_vif_driver is
127 139
 used.

+ 34
- 4
kuryr_kubernetes/controller/drivers/vif_pool.py View File

@@ -26,6 +26,7 @@ from oslo_cache import core as cache
26 26
 from oslo_concurrency import lockutils
27 27
 from oslo_config import cfg as oslo_cfg
28 28
 from oslo_log import log as logging
29
+from oslo_log import versionutils
29 30
 from oslo_serialization import jsonutils
30 31
 
31 32
 from kuryr_kubernetes import clients
@@ -61,6 +62,17 @@ vif_pool_driver_opts = [
61 62
                             "used. If not set, it will take them from the "
62 63
                             "kubernetes driver options for pool and pod "
63 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 76
                      default={}),
65 77
 ]
66 78
 
@@ -775,15 +787,16 @@ class MultiVIFPool(base.VIFPoolDriver):
775 787
 
776 788
     def set_vif_driver(self):
777 789
         self._vif_drvs = {}
778
-        pools_vif_drivers = oslo_cfg.CONF.vif_pool.pools_vif_drivers
779
-        if not pools_vif_drivers:
790
+        vif_pool_mapping = self._get_vif_pool_mapping()
791
+
792
+        if not vif_pool_mapping:
780 793
             pod_vif = oslo_cfg.CONF.kubernetes.pod_vif_driver
781 794
             drv_vif = base.PodVIFDriver.get_instance()
782 795
             drv_pool = base.VIFPoolDriver.get_instance()
783 796
             drv_pool.set_vif_driver(drv_vif)
784 797
             self._vif_drvs[pod_vif] = drv_pool
785 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 800
             if not utils.check_suitable_multi_pool_driver_opt(pool_driver,
788 801
                                                               pod_driver):
789 802
                 LOG.error("The pool and pod driver selected are not "
@@ -792,7 +805,7 @@ class MultiVIFPool(base.VIFPoolDriver):
792 805
             drv_vif = base.PodVIFDriver.get_instance(
793 806
                 specific_driver=pod_driver)
794 807
             drv_pool = base.VIFPoolDriver.get_instance(
795
-                specific_driver=pool_driver)
808
+                specific_driver=pool_driver, scope='for:{}'.format(pod_driver))
796 809
             drv_pool.set_vif_driver(drv_vif)
797 810
             self._vif_drvs[pod_driver] = drv_pool
798 811
 
@@ -839,3 +852,20 @@ class MultiVIFPool(base.VIFPoolDriver):
839 852
     def _get_vif_drv_alias(self, vif):
840 853
         vif_type_name = type(vif).__name__
841 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

+ 31
- 0
releasenotes/notes/reusable-pool-drivers-00e7fdc1f4738441.yaml View File

@@ -0,0 +1,31 @@
1
+---
2
+features:
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.
18
+upgrade:
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``.
23
+deprecations:
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.

Loading…
Cancel
Save