From cfb241ab63898eb4a550fc571d34952d33996e9c Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Mon, 30 Jul 2018 15:03:42 +0200 Subject: Protect vs exceptions when creating secrets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cloudify_ims sometimes faces with exceptions when creating secrets [1]. [1] https://build.opnfv.org/ci/view/functest/job/functest-apex-baremetal-daily-master/188/console Change-Id: I197748bf97752575dc14650e1e1c382774811cce Signed-off-by: Cédric Ollivier --- functest/opnfv_tests/vnf/ims/cloudify_ims.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index c5003e1c6..8fa8c612b 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -121,12 +121,23 @@ class CloudifyIms(cloudify.Cloudify): project_domain_name=os.environ.get( 'OS_PROJECT_DOMAIN_NAME', 'Default')) self.__logger.info("Set creds for cloudify manager %s", cfy_creds) - secrets_list = self.cfy_client.secrets.list() - for k, val in six.iteritems(cfy_creds): - if not any(d.get('key', None) == k for d in secrets_list): - self.cfy_client.secrets.create(k, val) - else: - self.cfy_client.secrets.update(k, val) + + for loop in range(10): + try: + secrets_list = self.cfy_client.secrets.list() + for k, val in six.iteritems(cfy_creds): + if not any(d.get('key', None) == k for d in secrets_list): + self.cfy_client.secrets.create(k, val) + else: + self.cfy_client.secrets.update(k, val) + break + except Exception: # pylint: disable=broad-except + self.__logger.info( + "try %s: Cannot create secrets", loop + 1) + time.sleep(30) + else: + self.__logger.error("Cannot create secrets") + return 1 duration = time.time() - start_time -- cgit 1.2.3-korg