Bug 1190245 - AutoYast rules and classes match against range does not work
AutoYast rules and classes match against range does not work
Status: CONFIRMED
Classification: openSUSE
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: AutoYaST
Current
Other Other
: P5 - None : Normal (vote)
: ---
Assigned To: YaST Team
E-mail List
https://trello.com/c/zlHf91H4/
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2021-09-07 09:18 UTC by Rainer König
Modified: 2021-09-07 14:46 UTC (History)
1 user (show)

See Also:
Found By: openQA
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
YaST2 log from failed attempt (198.77 KB, text/plain)
2021-09-07 09:18 UTC, Rainer König
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer König 2021-09-07 09:18:04 UTC
Created attachment 852337 [details]
YaST2 log from failed attempt

Trying out AutoYast Rules & Classes as it is described here: 
https://documentation.suse.com/sles/15-SP3/html/SLES-all/rulesandclass.html

The rules.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<autoinstall xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
  <rules config:type="list">
    <rule>
      <disksize>
        <match>/dev/sda 19000</match>
        <match_type>greater</match_type>
      </disksize>
      <result>
        <profile>profile_a.xml</profile>
        <continue config:type="boolean">false</continue>
      </result>
    </rule>
    <rule>
      <disksize>
        <match>/dev/vda 10000-19000</match>
        <match_type>range</match_type>
      </disksize>
      <result>
        <profile>profile_b.xml</profile>
        <continue config:type="boolean">false</continue>
      </result>
    </rule>
  </rules>
</autoinstall>

Trying to install on KVM with boot param "autoyast=http://myserver/rule-based_example/". AutoYast shows a dialog box that says "no profile found at this location". 
 it 
Looking at my local apache log I see, that it receives the rules/rules.xml, but then switches to defaults:

192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/rules/rules.xml HTTP/1.1" 200 732 "-" "-"
192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/C0A80046 HTTP/1.1" 404 984 "-" "-"
192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/C0A8004 HTTP/1.1" 404 984 "-" "-"
192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/C0A800 HTTP/1.1" 404 984 "-" "-"
192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/C0A80 HTTP/1.1" 404 984 "-" "-"
192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/C0A8 HTTP/1.1" 404 984 "-" "-"
192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/C0A HTTP/1.1" 404 984 "-" "-"
192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/C0 HTTP/1.1" 404 984 "-" "-"
192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/C HTTP/1.1" 404 984 "-" "-"
192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/52540095067E HTTP/1.1" 404 984 "-" "-"
192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/52540095067e HTTP/1.1" 404 984 "-" "-"
192.168.0.70 - - [07/Sep/2021:09:45:21 +0200] "GET /rule-based_example/default HTTP/1.1" 404 984 "-" "-"

Looking at the YaST-Log (see attachment) I see that the range match seems to work, but then I see a shell syntax error that probably causes AutoYast to switch to the default rules (as seen in the Apache access.log).

2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/AutoInstallRules.rb(block (2 levels) in Read):463 Rule: disksize
2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/AutoInstallRules.rb(block (2 levels) in Read):464 Ruledef: $["match":"/dev/vda 10000-49000", "match_type":"range"]
2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/AutoInstallRules.rb(block (2 levels) in Read):463 Rule: result
2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/AutoInstallRules.rb(block (2 levels) in Read):464 Ruledef: $["continue":false, "profile":"profile_b.xml"]
2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/AutoInstallRules.rb(SubVars):406 file: profile_b.xml
2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/AutoInstallRules.rb(SubVars):415 var: 
2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/AutoInstallRules.rb(SubVars):425 val: profile_b.xml
2021-09-07 03:45:17 <3> install(4435) [bash] ShellCommand.cc(shellcommand):78 sh: -c: line 3: syntax error near unexpected token `)'
2021-09-07 03:45:17 <3> install(4435) [bash] ShellCommand.cc(shellcommand):78 sh: -c: line 3: `if  (  ) ; then exit 0; else exit 1; fi'
2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/AutoInstallRules.rb(verifyrules):400 Bash return: if  (  ) ; then exit 0; else exit 1; fi ($["exit":2, "stderr":"sh: -c: line 3: syntax error near unexpected token `)'\nsh: -c: line 3: `if  (  ) ; then exit 0; else exit 1; fi'\n", "stdout":""]) ($["disksize_device0":"/dev/vda", "disksize_size0":40960])
2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/AutoInstallRules.rb(Read):640 element2file=$[]
2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/AutoInstallRules.rb(GetRules):815 Getting Rules: []
2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/AutoInstallRules.rb(GetRules):858 No files from rules found
2021-09-07 03:45:17 <1> install(4435) [Ruby] modules/ProfileLocation.rb(Process):251 Creating default Rules

Changing the rules.xml to 

      <disksize>
        <match>/dev/vda 10000</match>
        <match_type>greater</match_type>
      </disksize>

makes the AutoYast installation work. So the conclusion is that matching against a size range is broken because of that syntax error in the shell skript that is invoked.
Comment 1 Imobach Gonzalez Sosa 2021-09-07 14:43:01 UTC
Hi Rainer,

Thanks for reporting this bug. After checking the code, I would say that "range" matching type never was implemented for disksize (see https://github.com/imobachgs/yast-autoinstallation/blob/899c444fc4cb8fbd848f26eaea6f0dea4dcc8a2e/src/modules/AutoInstallRules.rb#L547-L583). I have checked different code streams and it seems it is missing in all of them.

So it is a valid bug that we need to fix.

Regards,
Imo