HomePhorge

(#14860) Fix puppet cert exit status on failures
0b01bb31e366Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(#14860) Fix puppet cert exit status on failures

Without this patch applied the following command errors out but does not
correctly set the exit status:

puppet cert generate foo.bar.com --dns_alt_names foo,foo.bar.com

The error returned is:

err: Could not call generate: CSR 'pe-internal-broker-test'
  contains subject alternative names (DNS:pe-centos6, \
  DNS:pe-centos6.puppetlabs.vm, DNS:pe-internal-broker-test, \
  DNS:stomp), which are disallowed. Use `puppet cert \
  --allow-dns-alt-names sign pe-internal-broker-test` to sign this \
  request.

However, the exit status is 0.

This is a problem because we need to easily detect if certificate
generation from the command line failed or succeeded. The most natural
and expected way to check this is by looking at the exit status.

The root cause of the problem is that
Puppet::SSL::CertificateAuthority::InterFace#apply incorrectly catches
and masks the exception raised by the generate method because it simply
logs an error with Puppet.err and continues along happily.

This patch fixes the problem by re-raising the error produced by
generate, allowing the application controller to catch the error
appropriately and exit with the non-zero exit status.

Details

Provenance
Jeff McCune <jeff@puppetlabs.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPUfb4c64b6a54b: Merge pull request #818 from lotheac/fix_http_report_desc
Branches
Unknown
Tags
Unknown

Event Timeline

Jeff McCune <jeff@puppetlabs.com> committed rPU0b01bb31e366: (#14860) Fix puppet cert exit status on failures (authored by Jeff McCune <jeff@puppetlabs.com>).Jun 7 2012, 1:11 AM