[stable-only] Add retry for inserting temp_ssh_key
For slow nodes, we don't wait for node to boot completely after the heat stack is CREATE/UPDATE_COMPLETE. This would ensure we try a few times before failing. Adds tenacity to requirements and bumps lower-constraints. Change-Id: Iee8f3200a3c108375c7ca296734db1a51914cd69 Closes-Bug: #1873892
This commit is contained in:
parent
5627d8d9cc
commit
da9dc6eb25
|
@ -143,7 +143,7 @@ statsd==3.2.1
|
|||
stestr==2.0.0
|
||||
stevedore==1.20.0
|
||||
Tempita==0.5.2
|
||||
tenacity==4.9.0
|
||||
tenacity==5.0.1
|
||||
testscenarios===0.4
|
||||
testtools==2.2.0
|
||||
tooz==1.58.0
|
||||
|
|
|
@ -16,6 +16,7 @@ simplejson>=3.5.1 # MIT
|
|||
six>=1.10.0 # MIT
|
||||
osc-lib>=1.8.0 # Apache-2.0
|
||||
websocket-client>=0.44.0 # LGPLv2+
|
||||
tenacity>=5.0.1 # Apache-2.0
|
||||
tripleo-common>=11.3.1 # Apache-2.0
|
||||
cryptography>=2.1 # BSD/Apache-2.0
|
||||
futures>=3.0.0;python_version=='2.7' or python_version=='2.6' # BSD
|
||||
|
|
|
@ -24,6 +24,7 @@ import yaml
|
|||
from heatclient.common import event_utils
|
||||
from openstackclient import shell
|
||||
import six
|
||||
import tenacity
|
||||
|
||||
from tripleoclient.constants import ENABLE_SSH_ADMIN_SSH_PORT_TIMEOUT
|
||||
from tripleoclient.constants import ENABLE_SSH_ADMIN_STATUS_INTERVAL
|
||||
|
@ -198,15 +199,11 @@ def get_hosts_and_enable_ssh_admin(
|
|||
enable_ssh_admin(log, clients, stack.stack_name, hosts,
|
||||
overcloud_ssh_user, overcloud_ssh_key,
|
||||
enable_ssh_timeout, enable_ssh_port_timeout)
|
||||
except subprocess.CalledProcessError as e:
|
||||
if e.returncode == 255:
|
||||
log.error("Could not import keys to one of {}. "
|
||||
"Original error message: {}\n".format(
|
||||
hosts, six.text_type(e)))
|
||||
else:
|
||||
log.error("Unknown error. "
|
||||
"Original error message:{}\n".format(
|
||||
six.text_type(e)))
|
||||
except (subprocess.CalledProcessError,
|
||||
tenacity.RetryError) as e:
|
||||
log.error("Could not import keys to one of {}. "
|
||||
"Original error message: {}\n".format(
|
||||
hosts, six.text_type(e)))
|
||||
raise
|
||||
|
||||
else:
|
||||
|
@ -216,6 +213,14 @@ def get_hosts_and_enable_ssh_admin(
|
|||
overcloud_ssh_network))
|
||||
|
||||
|
||||
@tenacity.retry(
|
||||
retry=tenacity.retry_if_exception_message(match="^.*exit status 255.*$"),
|
||||
wait=tenacity.wait_exponential(multiplier=1, max=60),
|
||||
stop=tenacity.stop_after_attempt(10))
|
||||
def copy_temp_key(command):
|
||||
subprocess.check_call(command, stderr=subprocess.STDOUT)
|
||||
|
||||
|
||||
def enable_ssh_admin(log, clients, plan_name, hosts, ssh_user, ssh_key,
|
||||
enable_ssh_timeout=ENABLE_SSH_ADMIN_TIMEOUT,
|
||||
enable_ssh_port_timeout=ENABLE_SSH_ADMIN_SSH_PORT_TIMEOUT
|
||||
|
@ -263,8 +268,7 @@ def enable_ssh_admin(log, clients, plan_name, hosts, ssh_user, ssh_key,
|
|||
"echo -e '\n%s' >> $HOME/.ssh/authorized_keys" %
|
||||
tmp_key_public_contents]
|
||||
print("Inserting TripleO short term key for %s" % host)
|
||||
subprocess.check_call(copy_tmp_key_command,
|
||||
stderr=subprocess.STDOUT)
|
||||
copy_temp_key(copy_tmp_key_command)
|
||||
|
||||
print("Starting ssh admin enablement workflow")
|
||||
|
||||
|
|
Loading…
Reference in New Issue