Issue #19411 has been updated by Charlie Sharpsteen.
Category changed from module tool to Faces
Status changed from Investigating to Needs Decision
Assignee changed from Charlie Sharpsteen to Andrew Parker
Allright, looks like this behavior is a result of the way faces behave in
general as the same logic pops up all over the place---`puppet module install`
is just one case and the rest can be found by running an `ack 'when_rendering
:console' on the Puppet source. The behavior in question is the result of the
`main` function in `puppet/application/face_base.rb` which can be simplified
as follows:
begin
result = @face.send(@action.name, *arguments)
puts render(result, arguments) unless result.nil?
status = true
rescue SystemExit => detail
status = detail.status
ensure
exit status
end
Unless the face action (`install` in this case) or the render method for that
action raises an exception, the code assumes everything is O.K. and exits with
a status of `true` which gets coerced to the 0 we are seeing. In the case of
console output, there is a `when_rendering :console` block defined for many
face actions that inspects `result` and calls `exit` with a non-zero code if
the result contained an error.
So, it appears that:
- This behavior is intentional, exit codes are only defined for console
output, as it is assumed that any process consuming structured output would be
able to easily determine that an error occured by parsing the JSON/YAML/etc.
- This behavior is not intentional. Within the existing system we could
define a `when_rendering :foo` block for each renderer foo, but that would be a
crazy duplication of code---so there needs to be some other solution like an
additional step added that examines `result` after the call to `render` and
sets the exit code appropriately.
I'm not sure which diagnosis is correct so I'm going to pass this off to
someone who has more experience with the design of the codebase.
----------------------------------------
Bug #19411: puppet module failures with JSON/YAML rendering have exit code 0
https://projects.puppetlabs.com/issues/19411#change-83973
Author: Dominic Cleal
Status: Needs Decision
Priority: Normal
Assignee: Andrew Parker
Category: Faces
Target version:
Affected Puppet version: development
Keywords:
Branch:
When using puppet module with default console rendering, the exit code changes
if there's a failure:
$ puppet module install error/error >/dev/null 2>&1; echo $?
1
However when running with JSON or YAML rendering, it isn't changed:
$ puppet module --render-as json install error/error >/dev/null 2>&1; echo
$?
0
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.