Allow disabling host-key-checking in statemachine

The statemachine driver was ignoring the host-key-checking option.
Correct that by passing it in as a parameter to the keyscan function.

Additionally, the Azure driver had a typo which initialized the
the value for host-key-checking to the wrong value.  Correct that.

Change-Id: Ie4a6b5e960b0a4906421924435b768ae545a2057
This commit is contained in:
James E. Blair 2021-12-10 16:07:37 -08:00
parent 21336dbafa
commit d832d209be
4 changed files with 13 additions and 4 deletions

View File

@ -218,7 +218,7 @@ class AzurePool(ConfigPool):
self.use_internal_ip = pool_config.get(
'use-internal-ip', self.provider.use_internal_ip)
self.host_key_checking = pool_config.get(
'host-key-checking', self.provider.use_internal_ip)
'host-key-checking', self.provider.host_key_checking)
@staticmethod
def getSchema():

View File

@ -122,6 +122,7 @@ class MetastaticInstance(statemachine.Instance):
self.shell_type = backing_node.shell_type
self.connection_port = backing_node.connection_port
self.connection_type = backing_node.connection_type
self.host_keys = backing_node.host_keys
backing_node_id = backing_node.id
else:
backing_node_id = None

View File

@ -73,6 +73,8 @@ class MetastaticPool(ConfigPool):
self.labels = {}
# We will just use the interface_ip of the backing node
self.use_internal_ip = False
self.host_key_checking = False
self.load(pool_config)
def load(self, pool_config):

View File

@ -32,7 +32,7 @@ from kazoo import exceptions as kze
import cachetools
def keyscan(node_id, interface_ip,
def keyscan(host_key_checking, node_id, interface_ip,
connection_type, connection_port,
timeout):
"""A standalone function for scanning keys to pass to a thread/process
@ -40,6 +40,8 @@ def keyscan(node_id, interface_ip,
"""
keys = []
if not host_key_checking:
return keys
try:
if (connection_type == 'ssh' or
connection_type == 'network_cli'):
@ -156,7 +158,8 @@ class StateMachineNodeLauncher(stats.StatsReporter):
# Optionally, if the node has updated values that we set from
# the image attributes earlier, set those.
for attr in ('username', 'python_path', 'shell_type',
'connection_port', 'connection_type'):
'connection_port', 'connection_type',
'host_keys'):
if hasattr(instance, attr):
setattr(node, attr, getattr(instance, attr))
@ -175,7 +178,8 @@ class StateMachineNodeLauncher(stats.StatsReporter):
if (self.state_machine.complete and self.keyscan_future
and self.keyscan_future.done()):
keys = self.keyscan_future.result()
node.host_keys = keys
if keys:
node.host_keys = keys
self.log.debug(f"Node {node.id} is ready")
node.state = zk.READY
self.zk.storeNode(node)
@ -206,6 +210,7 @@ class StateMachineNodeLauncher(stats.StatsReporter):
node.interface_ip)
future = self.manager.keyscan_worker.submit(
keyscan,
self.handler.pool.host_key_checking,
node.id, node.interface_ip,
node.connection_type, node.connection_port,
self.manager.provider.boot_timeout)
@ -717,6 +722,7 @@ class Instance:
* shell_type: str
* connection_port: str
* connection_type: str
* host_keys: [str]
"""
def __init__(self):
self.ready = False