Add retry for all requests to the Jenkins client on cluster
Change-Id: I69eccbebb58f3ce902abd11cf3926330e5fb2204
Related-Prod: #PROD-35718
diff --git a/tcp_tests/managers/reclass_manager.py b/tcp_tests/managers/reclass_manager.py
index f8895c6..137dd33 100644
--- a/tcp_tests/managers/reclass_manager.py
+++ b/tcp_tests/managers/reclass_manager.py
@@ -23,7 +23,7 @@
__config = None
__underlay = None
reclass_tools_cmd = ". venv-reclass-tools/bin/activate; reclass-tools "
- tgt = "cfg01" # place where the reclass-tools installed
+ tgt = "cfg01" # place where the reclass-tools installed
def __init__(self, config, underlay):
self.__config = config
@@ -38,11 +38,9 @@
def check_existence(self, key):
if key in self.ssh.check_call(
- "{reclass_tools} get-key {key} /srv/salt/reclass/classes"
- .format(
- reclass_tools=self.reclass_tools_cmd,
- key=key
- )):
+ "{reclass_tools} get-key {key} /srv/salt/reclass/classes".
+ format(reclass_tools=self.reclass_tools_cmd,
+ key=key)):
LOG.warning("({}) key already exists in reclass".format(key))
return True
return False
@@ -66,7 +64,7 @@
key=key,
value=value,
path=short_path
- ))
+ ))
def get_key(self, key, file_name):
"""Find a key in a YAML
@@ -75,6 +73,10 @@
:param file_name: name of YAML file to find a key
:return: str, key if found
"""
+ LOG.info("Try to get '{key}' key from '{file}' file".format(
+ file=file_name,
+ key=key
+ ))
request_key = self.ssh.check_call(
"{reclass_tools} get-key {key} /srv/salt/reclass/*/{file_name}".
format(reclass_tools=self.reclass_tools_cmd,
@@ -91,14 +93,13 @@
# '\n']
# So we have no chance to get value without dirty code like `stdout[3]`
- LOG.info("From reclass.get_key {}".format(request_key))
+ LOG.info("Raw output from reclass.get_key {}".format(request_key))
if len(request_key) < 4:
- assert "Can't find {key} in {file_name}. Got stdout {stdout}".\
- format(
- key=key,
- file_name=file_name,
- stdout=request_key
- )
+ print("Can't find {key} in {file_name}. Got stdout {stdout}".
+ format(key=key,
+ file_name=file_name,
+ stdout=request_key))
+ return None
value = request_key[3].strip('\n')
LOG.info("From reclass.get_key {}".format(value))
return value