nchammas / flintrock

A command-line tool for launching Apache Spark clusters.
Apache License 2.0
638 stars 116 forks source link

Error message wrong when putting a wrong User ID #130

Closed myeong closed 8 years ago

myeong commented 8 years ago

When I put a wrong user name for an AMI (the correct user name was "root", but I put my AWS user name) and I got this error.

Launching 6 instances...
There was a problem with the launch. Cleaning up...
Do you want to terminate the 6 instances created by this operation? [Y/n]: y
Terminating instances...
Traceback (most recent call last):
  File "/Users/myeong/anaconda/bin/flintrock", line 11, in <module>
    sys.exit(main())
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/flintrock/flintrock.py", line 871, in main
    cli(obj={})
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/flintrock/flintrock.py", line 322, in launch
    instance_initiated_shutdown_behavior=ec2_instance_initiated_shutdown_behavior)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/flintrock/ec2.py", line 46, in wrapper
    res = func(*args, **kwargs)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/flintrock/ec2.py", line 629, in launch
    identity_file=identity_file)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/flintrock/core.py", line 399, in provision_cluster
    _run_asynchronously(partial_func=partial_func, hosts=hosts)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/flintrock/core.py", line 365, in _run_asynchronously
    loop.run_until_complete(asyncio.gather(*tasks))
  File "/Users/myeong/anaconda/lib/python3.5/asyncio/base_events.py", line 337, in run_until_complete
    return future.result()
  File "/Users/myeong/anaconda/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/Users/myeong/anaconda/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/flintrock/core.py", line 452, in provision_node
    wait=True)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/flintrock/ssh.py", line 71, in get_ssh_client
    timeout=3)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/paramiko/client.py", line 307, in connect
    look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/paramiko/client.py", line 519, in _auth
    raise saved_exception
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/paramiko/client.py", line 444, in _auth
    key = pkey_class.from_private_key_file(key_filename, password)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/paramiko/pkey.py", line 184, in from_private_key_file
    key = cls(filename=filename, password=password)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/paramiko/ecdsakey.py", line 49, in __init__
    self._from_private_key_file(filename, password)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/paramiko/ecdsakey.py", line 145, in _from_private_key_file
    data = self._read_private_key_file('EC', filename, password)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/paramiko/pkey.py", line 256, in _read_private_key_file
    data = self._read_private_key(tag, f, password)
  File "/Users/myeong/anaconda/lib/python3.5/site-packages/paramiko/pkey.py", line 265, in _read_private_key
    raise SSHException('not a valid ' + tag + ' private key file')
paramiko.ssh_exception.SSHException: not a valid EC private key file

Just reporting that this error message needs to be fixed -- since it's not a key problem. Thanks!

nchammas commented 8 years ago

Hi @myeong, and thank you for using Flintrock.

Unfortunately, detecting when the provided username is incorrect is surprisingly difficult.

If you have any suggestions on how better to handle this situation I'm all ears!

myeong commented 8 years ago

Thanks for the quick response. For a quick and dirty solution, how about changing the error message something like "your AWS key or username has a problem"? I will keep exploring for the issue meanwhile :)

nchammas commented 8 years ago

When I put in an incorrect username, I get this error:

paramiko.ssh_exception.SSHException: Error reading SSH protocol banner[Errno 54] Connection reset by peer

So it's different from the error you see, which goes to my earlier comment about this being difficult to catch and report on properly without potentially confusing the user if the problem is actually something else.

I'm going to close this for now, but I am still interested in nudging the user in the right direction if it can be done without risking further confusion.

Maybe catching certain SSH exceptions and offering a hint of what might be wrong is the right thing to do. I'm not sure, but I would consider a PR that added this.