Skip to content

Commit

Permalink
teuthology/suite: merge base_config with other fragments
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
batrick committed Oct 18, 2024
1 parent 35e8b83 commit 7e5fc5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions teuthology/suite/merge.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
import itertools
import logging
import lupa
import os
Expand Down Expand Up @@ -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)

Expand All @@ -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()
Expand Down
1 change: 0 additions & 1 deletion teuthology/suite/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('-')
Expand Down

0 comments on commit 7e5fc5f

Please sign in to comment.