Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect_arista_eos raises exception against unix host #160

Closed
tyler-ball opened this issue Nov 4, 2016 · 6 comments · Fixed by #161
Closed

detect_arista_eos raises exception against unix host #160

tyler-ball opened this issue Nov 4, 2016 · 6 comments · Fixed by #161

Comments

@tyler-ball
Copy link
Contributor

Train version 0.21.0. Original stacktrace:

tball@delivery-server-acceptance:~$ sudo delivery-ctl install-runner -I /etc/delivery/chefdk-el7.rpm -f hostname --username ubuntu -i /etc/delivery/runners.pem -a tball -t 'token' -o -P none

Connecting to runner-acceptance-ubuntu1404-v2-1.builders-acceptance.shd.chef.co...
 (JSON::ParserError)ed/lib/ruby/gems/2.2.0/gems/json-2.0.2/lib/json/common.rb:156:in `parse': 743: unexpected token at 'bash: show: command not found
bash: json: command not found
'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/json-2.0.2/lib/json/common.rb:156:in `parse'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/extras/os_detect_arista_eos.rb:20:in `detect_arista_eos'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/extras/os_common.rb:127:in `detect_family_type'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/extras/os_common.rb:89:in `detect_family'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/extras/os_common.rb:31:in `initialize'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/transports/ssh_connection.rb:233:in `initialize'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/transports/ssh_connection.rb:58:in `new'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/transports/ssh_connection.rb:58:in `os'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/extras/command_wrapper.rb:165:in `load'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/transports/ssh_connection.rb:45:in `initialize'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/transports/ssh.rb:155:in `new'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/transports/ssh.rb:155:in `create_new_connection'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/transports/ssh.rb:75:in `connection'
	from /opt/delivery/embedded/service/omnibus-ctl/runner/remote_connection.rb:19:in `connect!'
	from /opt/delivery/embedded/service/omnibus-ctl/runner/installer.rb:49:in `install'
	from (eval):10:in `block in load_file'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/omnibus-ctl-0.3.6/lib/omnibus-ctl.rb:171:in `call'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/omnibus-ctl-0.3.6/lib/omnibus-ctl.rb:171:in `block in add_command'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/omnibus-ctl-0.3.6/lib/omnibus-ctl.rb:575:in `run'
	from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/omnibus-ctl-0.3.6/bin/omnibus-ctl:31:in `<top (required)>'
	from /opt/delivery/embedded/bin/omnibus-ctl:23:in `load'
	from /opt/delivery/embedded/bin/omnibus-ctl:23:in `<main>'

I have tried trying to access both an Ubuntu and Centos node using a Train connection.

connect_options => {:host=>"runner-acceptance-ubuntu1404-v2-1.builders-acceptance.shd.chef.co",
 :port=>22,
 :user=>"ubuntu",
 :key_files=>"/etc/delivery/runners.pem",
 :logger=>
  #<Logger:0x00000001b481c8
   @default_formatter=#<Logger::Formatter:0x00000001b481a0 @datetime_format=nil>,
   @formatter=nil,
   @level=0,
   @logdev=
    #<Logger::LogDevice:0x00000001b48150
     @dev=#<File:/var/log/delivery-ctl/runner-install_runner-acceptance-ubuntu1404-v2-1.builders-acceptance.shd.chef.co.log>,
     @filename="/var/log/delivery-ctl/runner-install_runner-acceptance-ubuntu1404-v2-1.builders-acceptance.shd.chef.co.log",
     @mutex=#<Logger::LogDevice::LogDeviceMutex:0x00000001b48128 @mon_count=0, @mon_mutex=#<Mutex:0x00000001b480d8>, @mon_owner=nil>,
     @shift_age=0,
     @shift_size=1048576>,
   @progname=nil>,
 :pty=>true,
 :sudo=>true,
 :sudo_password=>"none"}
@train = Train.create('ssh', connect_options)
@train.connection # fails
@tyler-ball
Copy link
Contributor Author

tyler-ball commented Nov 4, 2016

Adding pry debug points in os_common I can see that detect_linux returns true, but it is detect_arista_eos that fails. Looks like it is this line that is failing: https://github.com/chef/train/blob/master/lib/train/extras/os_detect_arista_eos.rb#L16

When I log into that host and try to run /bin/bash -c 'show version | json' I get:

ubuntu@ip-10-194-11-235:~$ /bin/bash -c 'show version | json'
/bin/bash: show: command not found
/bin/bash: json: command not found

@chris-rock
Copy link
Contributor

chris-rock commented Nov 4, 2016

I have a feeling why this happens. Not sure why this is not happening on my system though

@chris-rock
Copy link
Contributor

@tyler-ball Could you find out the result of https://github.com/chef/train/blob/master/lib/train/extras/os_detect_arista_eos.rb#L16
If the commands are not available, stdout should be empty, so the json should never be parsed

@tyler-ball
Copy link
Contributor Author

[1] pry(#<Train::Transports::SSH::Connection::OS>)> output
=> "bash: show: command not found\r\nbash: json: command not found\r\n"

@chris-rock
Copy link
Contributor

Why is the stderr piped into stdout?

@tyler-ball
Copy link
Contributor Author

Looks like it is piped to stdout because we enabled the PTY. Disabling the PTY in the connection settings results in

/opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/extras/command_wrapper.rb:169:in `load': Sudo failed: Sudo requires a TTY. Please see the README on how to configure sudo to allow for non-interactive usage. (Train::UserError)
from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/transports/ssh_connection.rb:45:in `initialize'
from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/transports/ssh.rb:155:in `new'
from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/transports/ssh.rb:155:in `create_new_connection'
from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/train-0.21.0/lib/train/transports/ssh.rb:75:in `connection'
from /opt/delivery/embedded/service/omnibus-ctl/runner/remote_connection.rb:19:in `connect!'
from /opt/delivery/embedded/service/omnibus-ctl/runner/installer.rb:49:in `install'
from (eval):10:in `block in load_file'
from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/omnibus-ctl-0.3.6/lib/omnibus-ctl.rb:171:in `call'
from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/omnibus-ctl-0.3.6/lib/omnibus-ctl.rb:171:in `block in add_command'
from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/omnibus-ctl-0.3.6/lib/omnibus-ctl.rb:575:in `run'
from /opt/delivery/embedded/lib/ruby/gems/2.2.0/gems/omnibus-ctl-0.3.6/bin/omnibus-ctl:31:in `<top (required)>'
from /opt/delivery/embedded/bin/omnibus-ctl:23:in `load'
from /opt/delivery/embedded/bin/omnibus-ctl:23:in `<main>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants