From 7e5fc5f19b27848d8a62e928a9c291d72487773b Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Fri, 18 Oct 2024 08:44:13 -0400 Subject: [PATCH] teuthology/suite: merge base_config with other fragments Presently the code tries to merge the base_config when the worker starts running. There's no need to construct it this way and it prevents sharing the "defaults" with the fragment merging infrastructure. It also prevents overriding defaults like: kernel branch: wip-pdonnell-i66704 client: branch: wip-pdonnell-i66704 flavor: default kdb: 1 sha1: 745cacd8f31e50d7f3b6039bbd8c9a8dfc07bf03 flavor: default kdb: 1 sha1: 745cacd8f31e50d7f3b6039bbd8c9a8dfc07bf03 A YAML fragment set kernel.client but it cannot delete the changes to kernel.(branch|flavor|kdb|sha1) because there's no way to remove YAML elements via a deep merge. Signed-off-by: Patrick Donnelly --- teuthology/suite/merge.py | 7 +++++-- teuthology/suite/run.py | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/teuthology/suite/merge.py b/teuthology/suite/merge.py index f13058e47..9c2f634d0 100644 --- a/teuthology/suite/merge.py +++ b/teuthology/suite/merge.py @@ -1,4 +1,5 @@ import copy +import itertools import logging import lupa import os @@ -115,13 +116,15 @@ def config_merge(configs, suite_name=None, **kwargs): the entire job (config) from the list. """ seed = kwargs.setdefault('seed', 1) + base_config = kwargs.setdefault('base_config', {}) if not isinstance(seed, int): log.debug("no valid seed input: using 1") seed = 1 log.debug("configuring Lua randomseed to %d", seed) L.execute(f'local math = require"math"; math.randomseed({seed});') new_script = L.eval('new_script') - yaml_cache = {} + base_config_path = '\0' # not a valid path + yaml_cache = {base_config_path: base_config} for desc, paths in configs: log.debug("merging config %s", desc) @@ -130,7 +133,7 @@ def config_merge(configs, suite_name=None, **kwargs): yaml_complete_obj = {} deep_merge(yaml_complete_obj, dict(TEUTHOLOGY_TEMPLATE)) - for path in paths: + for path in itertools.chain((base_config_path,), paths): if path not in yaml_cache: with open(path) as f: txt = f.read() diff --git a/teuthology/suite/run.py b/teuthology/suite/run.py index 7df601385..124d860f5 100644 --- a/teuthology/suite/run.py +++ b/teuthology/suite/run.py @@ -514,7 +514,6 @@ def collect_jobs(self, arch, configs, newest=False, limit=0): '--description', description, '--', ]) - arg.extend(self.base_yaml_paths) parsed_yaml_txt = yaml.dump(parsed_yaml) arg.append('-')