Skip to content

Commit

Permalink
Workaround an apparent problem with Mrack conversion of HW requiremen…
Browse files Browse the repository at this point in the history
…ts (#3443)

It seems that when only an actual filtering element is the filter, mrack
renders an element without attributes. It might be a mrack bug, or us
not understanding mrack API, but a quick workaround to unblock tmt is
possible. If it's a mrack bug, the proper fix may come later; if it's us
not giving mrack the correct structure, well, this patch fixes that. We
should be covered in both directions.

Fixes #3442
  • Loading branch information
happz authored Jan 8, 2025
1 parent 2af39b3 commit 9126daa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tmt/steps/provision/mrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,15 @@ def _translate_tmt_hw(self, hw: tmt.hardware.Hardware) -> dict[str, Any]:

logger.debug('Transformed hardware', tmt.utils.dict_to_yaml(transformed.to_mrack()))

# Mrack does not handle well situation when the filter
# consists of just a single filtering element, e.g. just
# `hostname`. In that case, the element is converted into
# XML element incorrectly. Therefore wrapping our filter
# with `<and/>` group, even if it has just a single child,
# it works around the problem.
# See https://github.com/teemtee/tmt/issues/3442
return {
'hostRequires': transformed.to_mrack()
'hostRequires': MrackHWAndGroup(children=[transformed]).to_mrack()
}

def create_host_requirement(self, host: CreateJobParameters) -> dict[str, Any]:
Expand Down

0 comments on commit 9126daa

Please sign in to comment.