Bug 1302950

Summary: Beaker injects extra <system_type/> if <hostRequires/> already contains <system_type/> nested inside other elements
Product: [Retired] Beaker Reporter: Dan Callaghan <dcallagh>
Component: generalAssignee: Dan Callaghan <dcallagh>
Status: CLOSED CURRENTRELEASE QA Contact: matt jia <mjia>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 22CC: dcallagh, dowang, jishi, jiyin, jwalters, kzhang, mjia, rjoost, zhchen
Target Milestone: 22.1Keywords: Patch, Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-01 04:31:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dan Callaghan 2016-01-29 06:19:49 UTC
Version-Release number of selected component (if applicable):
22.0

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

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

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

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 06:29:03 UTC
This is a regression in 22.0 due to a rather subtle mistake with the lxml conversion that we did.

http://gerrit.beaker-project.org/4647

Comment 2 Dan Callaghan 2016-01-29 06:33:39 UTC
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:

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

or simpler:

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

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-02-01 03:58:22 UTC
Verified steps:

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

2. Clone the job and the extra <system_type/> filter is not injected in the XML.

Comment 6 Dan Callaghan 2016-02-01 04:31:06 UTC
Beaker 22.1 has been released.