Skip to content

Commit c9b9f40

Browse files
happzpsss
authored andcommitted
Workaround an apparent problem with Mrack conversion of HW requirements
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
1 parent 2af39b3 commit c9b9f40

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tmt/steps/provision/mrack.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,15 @@ def _translate_tmt_hw(self, hw: tmt.hardware.Hardware) -> dict[str, Any]:
784784

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

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

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

0 commit comments

Comments
 (0)