Browse Source

Merge "Use same pool_driver for different pod_vif_drivers"

Zuul 2 months ago
parent
commit
53fba9a478

+ 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
 
@@ -819,15 +831,16 @@ class MultiVIFPool(base.VIFPoolDriver):
819 831
 
820 832
     def set_vif_driver(self):
821 833
         self._vif_drvs = {}
822
-        pools_vif_drivers = oslo_cfg.CONF.vif_pool.pools_vif_drivers
823
-        if not pools_vif_drivers:
834
+        vif_pool_mapping = self._get_vif_pool_mapping()
835
+
836
+        if not vif_pool_mapping:
824 837
             pod_vif = oslo_cfg.CONF.kubernetes.pod_vif_driver
825 838
             drv_vif = base.PodVIFDriver.get_instance()
826 839
             drv_pool = base.VIFPoolDriver.get_instance()
827 840
             drv_pool.set_vif_driver(drv_vif)
828 841
             self._vif_drvs[pod_vif] = drv_pool
829 842
             return
830
-        for pool_driver, pod_driver in pools_vif_drivers.items():
843
+        for pod_driver, pool_driver in vif_pool_mapping.items():
831 844
             if not utils.check_suitable_multi_pool_driver_opt(pool_driver,
832 845
                                                               pod_driver):
833 846
                 LOG.error("The pool and pod driver selected are not "
@@ -836,7 +849,7 @@ class MultiVIFPool(base.VIFPoolDriver):
836 849
             drv_vif = base.PodVIFDriver.get_instance(
837 850
                 specific_driver=pod_driver)
838 851
             drv_pool = base.VIFPoolDriver.get_instance(
839
-                specific_driver=pool_driver)
852
+                specific_driver=pool_driver, scope='for:{}'.format(pod_driver))
840 853
             drv_pool.set_vif_driver(drv_vif)
841 854
             self._vif_drvs[pod_driver] = drv_pool
842 855
 
@@ -887,3 +900,20 @@ class MultiVIFPool(base.VIFPoolDriver):
887 900
     def _get_vif_drv_alias(self, vif):
888 901
         vif_type_name = type(vif).__name__
889 902
         return VIF_TYPE_TO_DRIVER_MAPPING[vif_type_name]
903
+
904
+    def _get_vif_pool_mapping(self):
905
+        vif_pool_mapping = oslo_cfg.CONF.vif_pool.vif_pool_mapping
906
+
907
+        if not vif_pool_mapping:
908
+            pools_vif_drivers = oslo_cfg.CONF.vif_pool.pools_vif_drivers
909
+
910
+            if pools_vif_drivers:
911
+                msg = ("Config option vif_pool.pools_vif_drivers is "
912
+                       "deprecated in favour of vif_pool.vif_pool_mapping, "
913
+                       "and will be removed in a future release")
914
+                versionutils.report_deprecated_feature(LOG, msg)
915
+
916
+            for pool_driver, pod_driver in pools_vif_drivers.items():
917
+                vif_pool_mapping[pod_driver] = pool_driver
918
+
919
+        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