facebook / grocery-delivery

The Grocery Delivery utility for managing cookbook uploads to distributed Chef backends.
Apache License 2.0
154 stars 55 forks source link

Roles upload error #31

Closed clburlison closed 7 years ago

clburlison commented 7 years ago

Summary

grocery-delivery errors on upload if at least one rb style role isn't present in the chef repo.

Details

I tried to find the code responsible for this issue but couldn't quite locate it. I have a roles directory that only contains json files. When I run grocery-delivery with this chef repo I get the following error.

root@chef:~# /opt/opscode/embedded/bin/grocery-delivery
WARN: Attempting to acquire lock
WARN: Lock acquired
WARN: Updating repo
WARN: Uploading all cookbooks
WARN: Uploading all roles
ERROR: /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout.rb:289:in `invalid!'
ERROR: /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout.rb:276:in `error!'
ERROR: /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/between_meals-0.0.7/lib/between_meals/util.rb:42:in `exec!'
ERROR: /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/between_meals-0.0.7/lib/between_meals/knife.rb:56:in `role_upload_all'
ERROR: /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/grocery_delivery-0.0.7/bin/grocery-delivery:80:in `full_upload'
ERROR: /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/grocery_delivery-0.0.7/bin/grocery-delivery:166:in `upload_changed'
ERROR: /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/grocery_delivery-0.0.7/bin/grocery-delivery:277:in `<top (required)>'
ERROR: /opt/opscode/embedded/bin/grocery-delivery:22:in `load'
ERROR: /opt/opscode/embedded/bin/grocery-delivery:22:in `<main>'
WARN: Expected process to exit with [0], but received '1'
---- Begin output of /opt/opscode/bin/knife role from file /var/chef/grocery_delivery_work/cpe/roles/*.rb -c /root/.chef/knife.rb ----
STDOUT: 
STDERR: ERROR: Could not find or open file '/var/chef/grocery_delivery_work/cpe/roles/*.rb' in current directory or in 'roles//var/chef/grocery_delivery_work/cpe/roles/*.rb'
---- End output of /opt/opscode/bin/knife role from file /var/chef/grocery_delivery_work/cpe/roles/*.rb -c /root/.chef/knife.rb ----
Ran /opt/opscode/bin/knife role from file /var/chef/grocery_delivery_work/cpe/roles/*.rb -c /root/.chef/knife.rb returned 1

A simple solution is to create a test.rb roles with minimal content

name "test"
description "A test role so gd doesn't error."

which allows grocery-delivery to finish successfully. However it would be great if the above rb role limitation was removed.

jaymzh commented 7 years ago

So, between-meals allows you to specify a role-type, but GD doesn't take in this config. GD needs to get a new config which it can then pass to BetweenMeals::knife... should be a simple change.

To be clear, it's not that "just one rb role" won't fix you - it'll never upload JSON roles... because they're essentially deprecated, but we should still allow you to specify this.

jaymzh commented 7 years ago

The attached PR should be sufficient.

Note that we explicitly require you to pick either RB or JSON roles, you may not have both - we do those so they can never conflict.

clburlison commented 7 years ago

@jaymzh Thank you for the PR. I didn't realize that chef considered json roles deprecated since so many examples I find on the internet are shown using json.