Retry `get_and_verify_metadata` if metadata service is not available yet
The method verify_metadata_from_api gets info from the metadata api
and retries if the info does not match the expected result.
This patch makes the retries apply when the api does not reply/is not
available yet.
This is something that could happen due to a race condition:
- the VM is ACTIVE and accessible via ssh
- the metadata service is not up yet
Change-Id: Id94df05003fa0ba627acd836286a6fbb29012678
Signed-off-by: Eduardo Olivares <eolivare@redhat.com>
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 3ac2b46..3b44ded 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -560,8 +560,17 @@
'tagging metadata was not checked in the '
'metadata API')
return True
+
cmd = 'curl %s' % md_url
- md_json = ssh_client.exec_command(cmd)
+ try:
+ md_json = ssh_client.exec_command(cmd)
+ except lib_exc.SSHExecCommandFailed:
+ # NOTE(eolivare): We cannot guarantee that the metadata service
+ # is available right after the VM is ssh-able, because it could
+ # obtain authorized ssh keys from config_drive or it could use
+ # password. Hence, retries may be needed.
+ LOG.exception('metadata service not available yet')
+ return False
return verify_method(md_json)
# NOTE(gmann) Keep refreshing the metadata info until the metadata
# cache is refreshed. For safer side, we will go with wait loop of