sprinkle-tool / sprinkle

Sprinkle is a software provisioning tool you can use to build remote servers with. eg. to install a Rails, or Sinatra stack on a brand new slice directly after its been created
https://github.com/sprinkle-tool/sprinkle
MIT License
1.15k stars 138 forks source link

Errors from scp not propagated back? #71

Closed cleeland closed 12 years ago

cleeland commented 12 years ago

WARNING: I'm a noob with capistrano and sprinkle.

I just spent the better part of the day tracking down why I couldn't deploy. I'm trying to use sprinkle to push out development binaries (executables compiled and linked from C++ code) to a test server (ultimately I would like to extend sprinkle to control running the tests, but that's later). scp kept failing.

It turns out that the "problem" was that the very first binary it was trying to push out was running on the target, so scp was failing with a "text file busy" error. Either capistrano wasn't communicating that back to sprinkle, or sprinkle was squelching the error. In any case, it took more investigation and unrolling of the source to dig out an understanding of what was happening.

What should be reporting the error? Am I looking in the wrong place?

Finally, is this the best place to ask questions about sprinkle, or is there a better community forum?

joshgoebel commented 12 years ago

Please try my sprinkle/new_api branch. It should have much improved error reporting, I wonder if it catches your issue.

cleeland commented 12 years ago

Do I need to change my sprinkle setup? Do I need to uninstall the original installation of sprinkle or can I run your branch out of the clone/checkout? I get the following:

$ /home/ccleeland/localbuilds/sprinkle/bin/sprinkle -c -t -s install.rb
Only running policies for :
./exelerate.rb:6: undefined method `package' for main:Object (NoMethodError)
    from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from install.rb:1:in `sprinkle'
    from /home/ccleeland/localbuilds/sprinkle/bin/sprinkle:108
joshgoebel commented 12 years ago

What is in your install.rb? Perhaps pastie.org it.

cleeland commented 12 years ago

It's too big and has some local stuff that I'd rather not put on a public website, but I've reproduced the issue with a cut-down version:

$ /home/ccleeland/localbuilds/sprinkle/bin/sprinkle -s inst.rb 
Only running policies for :
./foo.rb:1: undefined method `package' for main:Object (NoMethodError)
    from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from inst.rb:1:in `sprinkle'
    from /home/ccleeland/localbuilds/sprinkle/bin/sprinkle:108
$ cat inst.rb 
require 'foo.rb'
policy :legacy, :roles => :core do
    requires :binaries
end
deployment do
    delivery :capistrano do
        recipes 'deploy.rb'
    end
end
$ cat deploy.rb
set :run_method, :run
#set :debug, true
#set :verbose, 1
default_run_options[:pty] = true
$ cat foo.rb
package :show_binaries, :provides => :binaries do
    %w{ls cat}.each do |bin|
        runner "ls -l /bin/#{bin}"
    end
end
cleeland commented 12 years ago

I have not done a "gem install". All I did was clone your repo, checkout the new_api branch, done a "rake build", and tried to run using a full path to sprinkle binary.

joshgoebel commented 12 years ago

Yeah, that could be your problem. What I do is a symlink.

~/git/sprinkle (my actual sprinkling working dir)

~/git/sprinkle_using_project (my actual app/sprinkle repository) ~/git/sprinkle_using_project/sprinkle -> ~/git/sprinkle/ (symlink to sprinkle repo)

cd ~/git/sprinkle_using_project ./sprinkle/bin/spinkle -args -whatever

Thanks, Josh Goebel

On Oct 9, 2012, at 5:59 PM, Chris Cleeland notifications@github.com wrote:

I have not done a "gem install". All I did was clone your repo, checkout the new_api branch, done a "rake build", and tried to run using a full path to sprinkle binary.

— Reply to this email directly or view it on GitHub.

cleeland commented 12 years ago

I did a "sudo rake install" and that improved things for my small case, but when I run it for my actual setup, I get the following:

$ sprinkle -c -s install.rb 
Only running policies for :
[legacy]
--> Cloud hierarchy for policy legacy
Policy legacy requires package exelerate_binaries
Selecting exelerate_binfiles for virtual package exelerate_binaries
/usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:315:in `select_package': undefined method `cloud_info' for # (NoMethodError)
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:273:in `tree'
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:271:in `each'
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:271:in `tree'
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:91:in `process'
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:82:in `each'
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:82:in `process'
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:79:in `process'
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:78:in `each'
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:78:in `process'
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/script.rb:20:in `sprinkle'
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/script.rb:16:in `sprinkle'
    from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/sprinkle:108
    from /usr/bin/sprinkle:19:in `load'
    from /usr/bin/sprinkle:19
joshgoebel commented 12 years ago

cloud_info isn't a defined method for a package, but I don't see where it has ever been.... hmmm... I don't use virtual packages, so I've never seen this. Let me switch to upstream.

Thanks, Josh Goebel

On Oct 9, 2012, at 6:24 PM, Chris Cleeland notifications@github.com wrote:

I did a "sudo rake install" and that improved things for my small case, but when I run it for my actual setup, I get the following:

$ sprinkle -c -s install.rb Only running policies for : [legacy] --> Cloud hierarchy for policy legacy

Policy legacy requires package exelerate_binaries Selecting exelerate_binfiles for virtual package exelerate_binaries /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:315:in select_package': undefined methodcloud_info' for # (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:273:in tree' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:271:ineach' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:271:in tree' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:91:inprocess' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:82:in each' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:82:inprocess' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:79:in process' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:78:ineach' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:78:in process' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/script.rb:20:insprinkle' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/script.rb:16:in sprinkle' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/sprinkle:108 from /usr/bin/sprinkle:19:inload' from /usr/bin/sprinkle:19 — Reply to this email directly or view it on GitHub.

joshgoebel commented 12 years ago

Are you saying your script works with master but not new_api?

joshgoebel commented 12 years ago

I just pushed a commit for new_api. Pull down the latest and give it another shot.

Thanks, Josh Goebel

On Oct 9, 2012, at 6:35 PM, Josh Goebel me@joshgoebel.com wrote:

cloud_info isn't a defined method for a package, but I don't see where it has ever been.... hmmm... I don't use virtual packages, so I've never seen this. Let me switch to upstream.

Thanks, Josh Goebel

On Oct 9, 2012, at 6:24 PM, Chris Cleeland notifications@github.com wrote:

I did a "sudo rake install" and that improved things for my small case, but when I run it for my actual setup, I get the following:

$ sprinkle -c -s install.rb Only running policies for : [legacy] --> Cloud hierarchy for policy legacy

Policy legacy requires package exelerate_binaries Selecting exelerate_binfiles for virtual package exelerate_binaries /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:315:in select_package': undefined methodcloud_info' for # (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:273:in tree' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:271:ineach' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:271:in tree' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:91:inprocess' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:82:in each' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:82:inprocess' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:79:in process' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:78:ineach' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:78:in process' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/script.rb:20:insprinkle' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/script.rb:16:in sprinkle' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/sprinkle:108 from /usr/bin/sprinkle:19:inload' from /usr/bin/sprinkle:19 — Reply to this email directly or view it on GitHub.

cleeland commented 12 years ago

I'll give it a shot in awhile

On Tuesday, October 9, 2012, Josh Goebel wrote:

I just pushed a commit for new_api. Pull down the latest and give it another shot.

Thanks, Josh Goebel

On Oct 9, 2012, at 6:35 PM, Josh Goebel <me@joshgoebel.com<javascript:_e({}, 'cvml', 'me@joshgoebel.com');>> wrote:

cloud_info isn't a defined method for a package, but I don't see where it has ever been.... hmmm... I don't use virtual packages, so I've never seen this. Let me switch to upstream.

Thanks, Josh Goebel

On Oct 9, 2012, at 6:24 PM, Chris Cleeland <notifications@github.com<javascript:_e({}, 'cvml', 'notifications@github.com');>> wrote:

I did a "sudo rake install" and that improved things for my small case, but when I run it for my actual setup, I get the following:

$ sprinkle -c -s install.rb Only running policies for : [legacy] --> Cloud hierarchy for policy legacy

Policy legacy requires package exelerate_binaries Selecting exelerate_binfiles for virtual package exelerate_binaries

/usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:315:in select_package': undefined methodcloud_info' for # (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:273:in tree' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:271:in each' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/package.rb:271:in tree' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:91:in process' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:82:in each' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/policy.rb:82:in process' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:79:in process' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:78:in each' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/deployment.rb:78:in process' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/script.rb:20:in sprinkle' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/../lib/sprinkle/script.rb:16:in sprinkle' from /usr/lib/ruby/gems/1.8/gems/sprinkle-0.5/bin/sprinkle:108 from /usr/bin/sprinkle:19:inload' from /usr/bin/sprinkle:19 — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/crafterm/sprinkle/issues/71#issuecomment-9282913.

Chris Cleeland

cleeland commented 12 years ago

With your change, it runs, but it miscomputes the dependencies/installation order and actually ends up doing a few of them twice.

I do, however, get stdout/stderr error messages back from the target system, which is nice.

I have a small test case that shows miscomputed normalization if you're interested.

Should I open an issue on your forked repo rather than discuss this here?

cleeland commented 12 years ago

I tried using git bisect with my test case to find the commit where things went awry, and ran into the same problem mentioned earlier in this thread with "undefined method 'package' for main:Object". I tried using the symlink technique you described and uninstalled the gem, but I still ended up with "undefined method 'package'".

joshgoebel commented 12 years ago

I think you should open a new ticket and tar your test case with output of the correct computation (from master I'd guess?) and the incorrect computation from new_api and attach that.

I'm going to close this ticket since new_api resolves the error reporting issue.

joshgoebel commented 12 years ago

There have been so many changes in new_api (and some commits along the way that probably don't even run on their own)... so I'm not sure a bisect is going to get the job done even if you get your local code running properly.

You can open that new ticket here or there.