intuit / simple_deploy

Maintenance Mode - Simple Deploy is an opinionated CLI tool for managing AWS Cloud Formation Stacks.
MIT License
64 stars 22 forks source link

Stacktrace error when trying to execute command on instances but instances are inaccessible. #155

Closed keviny22 closed 11 years ago

keviny22 commented 11 years ago

I stumbled on this issue when first setting up simple_deploy, but i failed to set the ssh user and ssh key environment variables for simple deploy; the exception is not getting handled properly.

It seems that there may be an issue in the codeblock in execute.rb

          begin
            stack.execute :command => @opts[:command],
                          :sudo    => @opts[:sudo]
          rescue SimpleDeploy::Exceptions::NoInstances
            logger.error "Stack has no running instances."
            exit 1
          end
$ simple_deploy execute -e default -n kyoung-testapp08 -c uptime -l debug
2013-02-13 11:05:27 -0800 DEBUG : Not using an ssh gateway.
2013-02-13 11:05:27 -0800 DEBUG : Setting user to kyoung.
2013-02-13 11:05:27 -0800 DEBUG : Setting key to /home/kyoung/.ssh/id_rsa.
2013-02-13 11:05:27 -0800 DEBUG : Executing command on instance 54.241.194.63.
2013-02-13 11:05:27 -0800 DEBUG : Executing command on instance 54.241.102.88.
2013-02-13 11:05:27 -0800 INFO : Setting command: 'uptime'.
2013-02-13 11:05:27 -0800 DEBUG :   * executing `execute'
2013-02-13 11:05:27 -0800 DEBUG :   * executing "uptime"
2013-02-13 11:05:27 -0800 DEBUG :     servers: ["54.241.194.63", "54.241.102.88"]
/home/kyoung/.rvm/gems/ruby-1.9.3-p374/gems/simple_deploy-0.6.6/lib/simple_deploy/cli/execute.rb:55:in `rescue in block in execute': uninitialized constant SimpleDeploy::Exceptions::NoInstances (NameError)
      from /home/kyoung/.rvm/gems/ruby-1.9.3-p374/gems/simple_deploy-0.6.6/lib/simple_deploy/cli/execute.rb:52:in `block in execute'
      from /home/kyoung/.rvm/gems/ruby-1.9.3-p374/gems/simple_deploy-0.6.6/lib/simple_deploy/cli/execute.rb:42:in `each'
      from /home/kyoung/.rvm/gems/ruby-1.9.3-p374/gems/simple_deploy-0.6.6/lib/simple_deploy/cli/execute.rb:42:in `execute'
      from /home/kyoung/.rvm/gems/ruby-1.9.3-p374/gems/simple_deploy-0.6.6/lib/simple_deploy/cli.rb:45:in `start'
      from /home/kyoung/.rvm/gems/ruby-1.9.3-p374/gems/simple_deploy-0.6.6/bin/simple_deploy:6:in `<top (required)>'
      from /home/kyoung/.rvm/gems/ruby-1.9.3-p374/bin/simple_deploy:23:in `load'
      from /home/kyoung/.rvm/gems/ruby-1.9.3-p374/bin/simple_deploy:23:in `<main>'
weavenet commented 11 years ago

Looks like I never added that exception class called NoInstances which inherits from Exceptions::Base in https://github.com/intuit/simple_deploy/blob/master/lib/simple_deploy/exceptions.rb

For a similar example, see CloudFormationError in https://github.com/intuit/stackster/blob/master/lib/stackster/exceptions.rb