Bug 1302950 - Beaker injects extra <system_type/> if <hostRequires/> already contains <system_type/> nested inside other elements
Beaker injects extra <system_type/> if <hostRequires/> already contains <syst...
Product: Beaker
Classification: Community
Component: general (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified (vote)
: 22.1
: ---
Assigned To: Dan Callaghan
matt jia
: Patch, Regression
Depends On:
  Show dependency treegraph
Reported: 2016-01-29 01:19 EST by Dan Callaghan
Modified: 2016-02-01 00:23 EST (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-01-31 23:31:06 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Dan Callaghan 2016-01-29 01:19:49 EST
Version-Release number of selected component (if applicable):

Steps to Reproduce:
1. Submit a job with <hostRequires/> like this:
    <hostname op="=" value="example.com"/>
    <system_type value="Prototype"/>
2. Clone the job to look at the XML

Actual results:
Beaker injects an extra contradictory <system_type/> filter:

          <system_type op="=" value="Prototype"/>
          <hostname op="=" value="example.invalid"/>
        <system_type value="Machine"/>

causing the recipe to abort with no matching systems.

Expected results:
Beaker should use the <hostRequires/> exactly as given, it should not inject any extra <system_type/> filter because there is already one present the job.

Additional info:
The workflow commands will produce a <hostRequires/> like the one above, because they always insert an <and/> at the top level. For example, this will submit a job to reproduce the bug:

bkr workflow-simple --family RedHatEnterpriseLinux7 --arch x86_64 --hostrequire 'hostname=example.invalid' --systype Prototype --task /distribution/reservesys
Comment 1 Dan Callaghan 2016-01-29 01:29:03 EST
This is a regression in 22.0 due to a rather subtle mistake with the lxml conversion that we did.

Comment 2 Dan Callaghan 2016-01-29 01:33:39 EST
Workaround is to change the <hostRequires/> so that it has a <system_type/> element as a top-level child. Using the example from comment 0 it could become either:

  <system_type value="Prototype"/>
    <hostname op="=" value="example.com"/>
    <system_type value="Prototype"/>

or simpler:

    <hostname op="=" value="example.com"/>
    <system_type value="Prototype"/>

or even just:

<hostRequires force="example.com"/>

Unfortunately if the job is being generated by a bkr workflow command, I cannot suggest any workaround because the workflow commands always unconditionally wrap the hostRequires inside an <and/> element.
Comment 5 matt jia 2016-01-31 22:58:22 EST
Verified steps:

1. Submit a job with <hostRequires/> like this:
    <hostname op="=" value="example.com"/>
    <system_type value="Prototype"/>

2. Clone the job and the extra <system_type/> filter is not injected in the XML.
Comment 6 Dan Callaghan 2016-01-31 23:31:06 EST
Beaker 22.1 has been released.

Note You need to log in before you can comment on or make changes to this bug.