'keys' must be defined for host-key-checking: false
If host-key-checking is set to false the aws driver fails with an UnboundLocalError Change-Id: I91ec292a48e283f9fb8d60b944da8eaf1bec393b
This commit is contained in:
parent
e391572495
commit
ec9a532cdd
@ -230,6 +230,7 @@ class AwsProviderConfig(ProviderConfig):
|
|||||||
pool.update({
|
pool.update({
|
||||||
v.Required('name'): str,
|
v.Required('name'): str,
|
||||||
v.Required('labels'): [pool_label],
|
v.Required('labels'): [pool_label],
|
||||||
|
'host-key-checking': bool,
|
||||||
'security-group-id': str,
|
'security-group-id': str,
|
||||||
'subnet-id': str,
|
'subnet-id': str,
|
||||||
})
|
})
|
||||||
|
@ -80,6 +80,7 @@ class AwsInstanceLauncher(NodeLauncher):
|
|||||||
|
|
||||||
self.node.connection_port = self.label.cloud_image.connection_port
|
self.node.connection_port = self.label.cloud_image.connection_port
|
||||||
self.node.connection_type = self.label.cloud_image.connection_type
|
self.node.connection_type = self.label.cloud_image.connection_type
|
||||||
|
keys = []
|
||||||
if self.pool.host_key_checking:
|
if self.pool.host_key_checking:
|
||||||
try:
|
try:
|
||||||
if (self.node.connection_type == 'ssh' or
|
if (self.node.connection_type == 'ssh' or
|
||||||
|
11
nodepool/tests/fixtures/aws.yaml
vendored
11
nodepool/tests/fixtures/aws.yaml
vendored
@ -9,6 +9,7 @@ labels:
|
|||||||
- name: ubuntu1404-by-filters
|
- name: ubuntu1404-by-filters
|
||||||
- name: ubuntu1404-by-capitalized-filters
|
- name: ubuntu1404-by-capitalized-filters
|
||||||
- name: ubuntu1404-bad-config
|
- name: ubuntu1404-bad-config
|
||||||
|
- name: ubuntu1404-non-host-key-checking
|
||||||
|
|
||||||
providers:
|
providers:
|
||||||
- name: ec2-us-west-2
|
- name: ec2-us-west-2
|
||||||
@ -66,3 +67,13 @@ providers:
|
|||||||
cloud-image: ubuntu1404-bad-config
|
cloud-image: ubuntu1404-bad-config
|
||||||
instance-type: t3.medium
|
instance-type: t3.medium
|
||||||
key-name: zuul
|
key-name: zuul
|
||||||
|
- name: non-host-key-checking
|
||||||
|
max-servers: 1
|
||||||
|
subnet-id: null
|
||||||
|
security-group-id: null
|
||||||
|
host-key-checking: false
|
||||||
|
labels:
|
||||||
|
- name: ubuntu1404-non-host-key-checking
|
||||||
|
cloud-image: ubuntu1404
|
||||||
|
instance-type: t3.medium
|
||||||
|
key-name: zuul
|
||||||
|
@ -63,8 +63,12 @@ class TestDriverAws(tests.DBTestCase):
|
|||||||
}
|
}
|
||||||
raw_config['providers'][0]['pools'][0]['subnet-id'] = subnet_id
|
raw_config['providers'][0]['pools'][0]['subnet-id'] = subnet_id
|
||||||
raw_config['providers'][0]['pools'][0]['security-group-id'] = sg_id
|
raw_config['providers'][0]['pools'][0]['security-group-id'] = sg_id
|
||||||
|
raw_config['providers'][0]['pools'][1]['subnet-id'] = subnet_id
|
||||||
|
raw_config['providers'][0]['pools'][1]['security-group-id'] = sg_id
|
||||||
|
|
||||||
def _test_run_node(label, is_valid_config=True):
|
def _test_run_node(label,
|
||||||
|
is_valid_config=True,
|
||||||
|
host_key_checking=True):
|
||||||
with tempfile.NamedTemporaryFile() as tf:
|
with tempfile.NamedTemporaryFile() as tf:
|
||||||
tf.write(yaml.safe_dump(
|
tf.write(yaml.safe_dump(
|
||||||
raw_config, default_flow_style=False).encode('utf-8'))
|
raw_config, default_flow_style=False).encode('utf-8'))
|
||||||
@ -95,11 +99,12 @@ class TestDriverAws(tests.DBTestCase):
|
|||||||
self.assertEqual(node.state, zk.READY)
|
self.assertEqual(node.state, zk.READY)
|
||||||
self.assertIsNotNone(node.launcher)
|
self.assertIsNotNone(node.launcher)
|
||||||
self.assertEqual(node.connection_type, 'ssh')
|
self.assertEqual(node.connection_type, 'ssh')
|
||||||
nodescan.assert_called_with(
|
if host_key_checking:
|
||||||
node.interface_ip,
|
nodescan.assert_called_with(
|
||||||
port=22,
|
node.interface_ip,
|
||||||
timeout=180,
|
port=22,
|
||||||
gather_hostkeys=True)
|
timeout=180,
|
||||||
|
gather_hostkeys=True)
|
||||||
|
|
||||||
# A new request will be paused and for lack of quota
|
# A new request will be paused and for lack of quota
|
||||||
# until this one is deleted
|
# until this one is deleted
|
||||||
@ -136,8 +141,11 @@ class TestDriverAws(tests.DBTestCase):
|
|||||||
{"label": "ubuntu1404-by-capitalized-filters"},
|
{"label": "ubuntu1404-by-capitalized-filters"},
|
||||||
{"label": "ubuntu1404-bad-ami-name", "is_valid_config": False},
|
{"label": "ubuntu1404-bad-ami-name", "is_valid_config": False},
|
||||||
{"label": "ubuntu1404-bad-config", "is_valid_config": False},
|
{"label": "ubuntu1404-bad-config", "is_valid_config": False},
|
||||||
|
{"label": "ubuntu1404-non-host-key-checking",
|
||||||
|
"host_key_checking": False},
|
||||||
]
|
]
|
||||||
|
|
||||||
for cloud_image in cloud_images:
|
for cloud_image in cloud_images:
|
||||||
_test_run_node(cloud_image["label"],
|
_test_run_node(cloud_image["label"],
|
||||||
cloud_image.get("is_valid_config"))
|
cloud_image.get("is_valid_config"),
|
||||||
|
cloud_image.get("host_key_checking"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user