Bug 475541

Summary: Wrong parsing of %%post section from kickstarts.
Product: [Fedora] Fedora Reporter: Vadim Grinco <vgrinco>
Component: anacondaAssignee: Anaconda Maintenance Team <anaconda-maint-list>
Status: CLOSED INSUFFICIENT_DATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 10CC: anaconda-maint-list, vfalico
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-06-18 18:15:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
ks.cfg none

Description Vadim Grinco 2008-12-09 16:28:58 UTC
Description of problem:

Anaconda doesn't parse %%post section correctly in ks.cfg.

How reproducible:
Kick F10 from nfs://bigpapi.bos.redhat.com/vol/engineering/redhat/released/F-10/GOLD/Fedora/x86_64/os with the ks.cfg attached or run `test_lab_machine.py -r -S rhts.redhat.com -t /distribution/inventory -u jgrando -a x86_64 -m dell-pe1950-01.rhts.bos.redhat.com -f Fedora10` if you have rhts-scheduler-workflows installed.

Actual results:

15:02:25 ERROR   : Error code 127 encountered running the kickstart script at line 253

Expected results:

Successful execution of the script.

Additional info:

Tested on dell-pe1950-01.rhts.bos.redhat.com. Works with F10 distribution from http://mirror.englab.brq.redhat.com/fedora/10/Fedora/x86_64/os/

Comment 1 Vadim Grinco 2008-12-09 16:30:02 UTC
Created attachment 326348 [details]
anaconda.log

Comment 2 Vadim Grinco 2008-12-09 16:31:18 UTC
Created attachment 326349 [details]
ks.cfg

Comment 3 Chris Lumens 2008-12-10 16:41:10 UTC
If I run ksvalidator on the script and do a little poking around in pdb, I find that the script in question is:

(Pdb) handler.scripts[1].lineno
253
(Pdb) handler.scripts[1].script
'/bin/cp /etc/resolv.conf /mnt/sysimage/etc/resolv.conf\n\n'

I don't see how there could be a parse error here, unless subprocess really doesn't like things to end with a newline.  The error message you're seeing usually happens when there was an error running the script itself.  For instance:  is there even a /etc/resolv.conf file to copy?  What makes you think there's a parse error here?

Comment 4 Vadim Grinco 2008-12-10 17:09:48 UTC
Chris,

When I asked jgranado he didn't say anything about line 253 in the post scripts, and I assumed that the error below means line 253 in ks.cfg itself.

From anaconda.log:
15:02:25 INFO    : Running kickstart %%post script(s)
15:02:25 ERROR   : Error code 127 encountered running the kickstart script at line 253
15:02:47 INFO    : All kickstart %%post script(s) have been run


From ks.cfg:
   251	cat << __EOT__ > /etc/yum.repos.d/rhts-tests.repo
   252	[rhts-noarch]
   253	name=Fedora10 - \$basearch - rhts development
   254	baseurl=http://rhts.redhat.com/rpms/development/noarch/noarch
   255	enabled=1
   256	gpgcheck=0
   257	__EOT__


I tried to run the same test on two diferrent lab controllers, on the same hardware (ks.cfg is the same, except  rhts specific variables and distro location) and it failed to install F10 from `nfs --server=bigpapi.bos.redhat.com --dir=/vol/engineering/redhat/released/F-10/GOLD/Fedora/x86_64/os` but succeeded from `nfs --server=filer-eng.brq.redhat.com --dir=/vol/mirrors/engineering/fedora/10/Fedora/x86_64/os`

vfalico had a similar issue.

Comment 5 Veaceslav Falico 2008-12-10 17:22:57 UTC
Error 127 means that the _program_ does not exist. 

[vfalico@dhcp-lab-150 tests]$ /bin/cp /etc/resolv.conf ~/; echo $?
0
[vfalico@dhcp-lab-150 tests]$ /bin/cp /etc/resolv.conf1 ~/; echo $?
/bin/cp: cannot stat `/etc/resolv.conf1': No such file or directory
1
[vfalico@dhcp-lab-150 tests]$ /bin/cp1 /etc/resolv.conf ~/; echo $?
bash: /bin/cp1: No such file or directory
127
[vfalico@dhcp-lab-150 tests]$ 

In F10 the ks %post script is executed in chroot'ed environment, from python, so I think it's somewhat regarding the chroot. I have similar bugs in sumo other distributions. If I'll find anything, I'll write here...

Comment 6 Chris Lumens 2008-12-10 18:01:32 UTC
When I download the attachment and open it in vim, line 253 is this:

%post --nochroot

Since this is the only nochroot script in the kickstart file, I'm willing to believe that we're not handling this right.  I haven't tested it recently, but I also haven't made any changes here.  It's certainly worth investigating.  I could set up a test real quick, or you could add something to your %post script to show the contents of /.  This would tell us whether --nochroot was working or not:

%post --nochroot
ls / > /tmp/LS

Then it's just a matter of if LS ends up in /tmp/LS or /mnt/sysimage/tmp/LS.

Comment 7 Vadim Grinco 2008-12-10 18:57:20 UTC
Chris,

You're right. I forgot that nl doesn't number empty lines by default. 

Will do that and update you.

Vadim