[autoscaler] better message if there are more than 10 key pairs

This commit is contained in:
Eric Liang 2018-10-26 12:42:11 -07:00 committed by GitHub
parent b4614ae69a
commit 055daf17a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -115,7 +115,8 @@ def _configure_key_pair(config):
ec2 = _resource("ec2", config)
# Try a few times to get or create a good key pair.
for i in range(10):
MAX_NUM_KEYS = 20
for i in range(MAX_NUM_KEYS):
key_name, key_path = key_pair(i, config["provider"]["region"])
key = _get_key(key_name, config)
@ -132,7 +133,12 @@ def _configure_key_pair(config):
os.chmod(key_path, 0o600)
break
assert key, "AWS keypair {} not found for {}".format(key_name, key_path)
if not key:
raise ValueError(
"No matching local key file for any of the key pairs in this "
"account with ids from 0..{}. ".format(key_name) +
"Consider deleting some unused keys pairs from your account.")
assert os.path.exists(key_path), \
"Private key file {} not found for {}".format(key_path, key_name)