FredHutch / kwik-e-mart

This is the private version of a cookbook for publishing cookbooks to a supermarket and to a chef server
0 stars 0 forks source link

Error checking for duplicate version in supermarket #2

Open atombaby opened 8 years ago

atombaby commented 8 years ago

Currently a duplicate version causes ugly failures- clean these up and provide a sensible error for upstream consumption

Current messages:

[2016-05-21T01:58:34+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-05-21T01:58:34+00:00] ERROR: execute[upload to supermarket] (kwik-e-mart::upload line 59) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of knife supermarket share congenial-happiness -o .. --config /var/spool/btb/.chef/knife.rb --verbose ----
STDOUT: INFO: Using configuration from /var/spool/btb/.chef/knife.rb
INFO: Validating ruby files
INFO: Validating templates
INFO: Syntax OK
STDERR: Generating metadata for congenial-happiness from /tmp/chef-congenial-happiness-build20160521-22607-1ewss4e/congenial-happiness/metadata.rb
Making tarball congenial-happiness.tgz
ERROR: Version has already been taken
---- End output of knife supermarket share congenial-happiness -o .. --config /var/spool/btb/.chef/knife.rb --verbose ----
Ran knife supermarket share congenial-happiness -o .. --config /var/spool/btb/.chef/knife.rb --verbose returned 1
[2016-05-21T01:58:35+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
atombaby commented 8 years ago

This is trickier than it looks- we want the recipe to fail when a condition succeeds (i.e. when knife supermarket show cookbook version returns 0) which is not a readily apparent capability. It is possible to reverse the exit of the shell command (command && exit 1 || exit 0) but the error messages are no better.

As it stands, the recipe functions as necessary- if there's a duplicate version, the converge fails. This kind of guard would hopefully provide a cleaner message for upstream consumption, but as it stands, the message is in there and available for diagnosis