]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
provision/downburst: support multiple config per machine_type 2077/head
authorKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Sun, 24 Aug 2025 12:00:58 +0000 (14:00 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Tue, 26 Aug 2025 19:36:27 +0000 (21:36 +0200)
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@clyso.com>
teuthology/lock/ops.py
teuthology/lock/util.py
teuthology/provision/downburst.py

index 52dce685754c772c1aff15cb6b05527a56af48d2..4fb6ba86a51aeb0189314e0ebbf2235f9145cd68 100644 (file)
@@ -76,18 +76,20 @@ def lock_many(ctx, num, machine_type, user=None, description=None,
     # all in one shot. If we are passed 'plana,mira,burnupi,vps', do one query
     # for 'plana,mira,burnupi' and one for 'vps'
     machine_types_list = misc.get_multi_machine_types(machine_type)
-    if machine_types_list == ['vps']:
+    downburst_types = teuthology.provision.downburst.get_types()
+    if all(t in downburst_types for t in machine_types_list):
         machine_types = machine_types_list
     elif machine_types_list == ['openstack']:
         return lock_many_openstack(ctx, num, machine_type,
                                    user=user,
                                    description=description,
                                    arch=arch)
-    elif 'vps' in machine_types_list:
-        machine_types_non_vps = list(machine_types_list)
-        machine_types_non_vps.remove('vps')
-        machine_types_non_vps = '|'.join(machine_types_non_vps)
-        machine_types = [machine_types_non_vps, 'vps']
+    elif any(t in downburst_types for t in machine_types_list):
+        the_vps = list(t for t in machine_types_list
+                                        if t in downburst_types)
+        non_vps = list(t for t in machine_types_list
+                                        if not t in downburst_types)
+        machine_types = ['|'.join(non_vps), '|'.join(the_vps)]
     else:
         machine_types_str = '|'.join(machine_types_list)
         machine_types = [machine_types_str, ]
@@ -102,9 +104,9 @@ def lock_many(ctx, num, machine_type, user=None, description=None,
         )
         # Only query for os_type/os_version if non-vps and non-libcloud, since
         # in that case we just create them.
-        vm_types = ['vps'] + teuthology.provision.cloud.get_types()
+        vm_types = downburst_types + teuthology.provision.cloud.get_types()
         reimage_types = teuthology.provision.get_reimage_types()
-        if machine_type not in vm_types + reimage_types:
+        if machine_type not in (vm_types + reimage_types):
             if os_type:
                 data['os_type'] = os_type
             if os_version:
index 91f957eab7e18233e32f7905bd6d3c70f0642d5f..955b97e43dd4d82575f8fee1cd177816e8dd329b 100644 (file)
@@ -18,7 +18,7 @@ def vps_version_or_type_valid(machine_type, os_type, os_version):
     is skipped (so that this code should behave as it did before this
     check was added).
     """
-    if not machine_type == 'vps':
+    if not (machine_type in teuthology.provision.downburst.get_types()):
         return True
     if os_type is None or os_version is None:
         # we'll use the defaults provided by provision.create_if_vm
index 3dc3c2e826a325f8cac5879d99cd7f7e062db4ca..a776bc2834845d79d91d08b0e08530fd609f8088 100644 (file)
@@ -14,6 +14,15 @@ from teuthology.lock import query
 log = logging.getLogger(__name__)
 
 
+def get_types():
+    types = ['vps']
+    if 'downburst' in config and 'machine' in config.downburst:
+        machine = config.downburst.get('machine')
+        if isinstance(machine, list):
+            types = list(m.get('type') for m in machine)
+    return types
+
+
 def downburst_executable():
     """
     First check for downburst in the user's path.
@@ -186,24 +195,32 @@ class Downburst(object):
         os_version = self.os_version.lower()
 
         mac_address = self.status['mac_address']
-        defaults = dict(
-            downburst=dict(
-                machine=dict(
-                    disk=os.environ.get('DOWNBURST_DISK_SIZE', '100G'),
-                    ram=os.environ.get('DOWNBURST_RAM_SIZE', '3.8G'),
-                    cpus=int(os.environ.get('DOWNBURST_CPUS', 1)),
-                    volumes=dict(
-                        count=int(os.environ.get('DOWNBURST_EXTRA_DISK_NUMBER', 4)),
-                        size=os.environ.get('DOWNBURST_EXTRA_DISK_SIZE', '100G'),
-                    ),
-                ),
-            )
+        machine = dict(
+            disk=os.environ.get('DOWNBURST_DISK_SIZE', '100G'),
+            ram=os.environ.get('DOWNBURST_RAM_SIZE', '3.8G'),
+            cpus=int(os.environ.get('DOWNBURST_CPUS', 1)),
+            volumes=dict(
+                count=int(os.environ.get('DOWNBURST_EXTRA_DISK_NUMBER', 4)),
+                size=os.environ.get('DOWNBURST_EXTRA_DISK_SIZE', '100G'),
+            ),
         )
-        downburst_config = defaults['downburst']
-        if config.downburst and isinstance(config.downburst, dict):
-            deep_merge(downburst_config, config.downburst)
-        log.debug('downburst_config: %s', downburst_config)
-        machine = downburst_config['machine']
+        def belongs_machine_type(machine_config: dict, machine_type: str) -> bool:
+            if isinstance(machine_config, dict):
+                t = machine_config.get('type', None)
+                if isinstance(t, str):
+                    return machine_type == t
+                elif isinstance(t, list):
+                    return machine_type in t
+            return False
+        if isinstance(config.downburst, dict) and isinstance(config.downburst.get('machine'), list):
+            machine_type = self.status['machine_type']
+            machine_config = next((m for m in config.downburst.get('machine')
+                        if belongs_machine_type(m, machine_type)), None)
+            if machine_config is None:
+                raise RuntimeError(f"Cannot find config for machine type {machine_type}.")
+        elif isinstance(config.downburst, dict) and isinstance(config.downburst.get('machine'), dict):
+            machine_config = config.downburst.get('machine')
+        deep_merge(machine, machine_config)
         log.debug('Using machine config: %s', machine)
         file_info = {
             'disk-size': machine['disk'],