rpm exits 0 on scriptlet failure

525 views
Skip to first unread message

Raul Macian

unread,
Jul 2, 2014, 2:51:10 PM7/2/14
to puppet...@googlegroups.com
I have a problem that starts to make me think that puppet is not usable to install packages. I will explain:

There is a common situation when you put some code on the %post when creating rpm. In my case I am executing some db migrations after the installation has been performed. The problems rises when something goes wrong in the scriptlet because the yum command will ignore the failure end exits with a succesful code. To add more complexity the yum provider performs a yum -q command, that means no output on your logs. So you don't know if the installation has ended ok or not.

Here explains some things exposed

Christopher Wood

unread,
Jul 2, 2014, 5:21:46 PM7/2/14
to puppet...@googlegroups.com
This is where my mileage varies from yours; I would have the rpm install files and leave the data munging to an exec or type/provider where the error will show through to puppet. I don't see a puppet issue here, in the same manner that a bug in an init script is not a puppet service (type) issue.

I've never been on board the do-complicated-things-in-rpms train and your experience is why.
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/341271db-3ac7-4330-ba23-4dd6a1f51952%40googlegroups.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/341271db-3ac7-4330-ba23-4dd6a1f51952%40googlegroups.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout

jcbollinger

unread,
Jul 3, 2014, 2:18:54 PM7/3/14
to puppet...@googlegroups.com


On Wednesday, July 2, 2014 9:51:10 AM UTC-5, Raul Macian wrote:
I have a problem that starts to make me think that puppet is not usable to install packages. I will explain:



That's a whopper of a claim.  Don't let any of the thousands of people who do use Puppet to install packages hear it.  :^)

 
There is a common situation when you put some code on the %post when creating rpm.


Not, it's really not.  I mean %post scriptlets themselves are pretty common, but scriptlets exiting nonzero is almost always bad form.  For instance, RedHat says, "Except in some really exceptional cases (if any), we want all scriptlets to exit with the zero exit status" (Fedora packaging guidelines, http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Syntax).  The Fedora guidelines go into more detail about why, but I'll summarize it as "scriptlets exiting nonzero messes you up".

 
In my case I am executing some db migrations after the installation has been performed. The problems rises when something goes wrong in the scriptlet because the yum command will ignore the failure end exits with a succesful code. To add more complexity the yum provider performs a yum -q command, that means no output on your logs. So you don't know if the installation has ended ok or not.



It's a Bad Thing if the installation does not end ok on account of a scriptlet failing.  Better would be for the scriptlet to record status information somewhere on the filesystem if the fact that it did not complete the intended work will not otherwise be evident.  If your scriptlet did so, then you could test the output via an Exec to feed that information back into Puppet.

 


The bottom line is that the issue described there is with RPM, therefore so is your complaint.  If RPM does not behave as you require, then don't use RPM packages.  This is not a Puppet issue.

For what its worth, I tend to agree that RPM ought not to exit with a success code if a scriptlet has failed.  On the other hand, RedHat's position, to which I subscribe, is that you oughtn't to be packaging scriptlets that ever can fail.


John

Reply all
Reply to author
Forward
0 new messages