Skip to content

Commit

Permalink
add possibility to not retry the connection on first attempt
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Horak <[email protected]>
  • Loading branch information
dahorak committed Jul 18, 2024
1 parent 86b2f6c commit 786b52d
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def setup_teardown(self, request):
6:- Delete ocs nfs Service
"""
self.__nfs_client_connection = None
self = request.node.cls
log.info("-----Setup-----")
self.namespace = "openshift-storage"
Expand Down Expand Up @@ -207,7 +206,9 @@ def con(self):
or not self.__nfs_client_connection
):
try:
self.__nfs_client_connection = self.get_nfs_client_connection()
self.__nfs_client_connection = self.get_nfs_client_connection(
re_try=False
)
except (TimeoutError, socket.gaierror):
nfs_client_vm_cloud = config.ENV_DATA.get("nfs_client_vm_cloud")
nfs_client_vm_name = config.ENV_DATA.get("nfs_client_vm_name")
Expand All @@ -218,17 +219,22 @@ def con(self):
self.__nfs_client_connection = self.get_nfs_client_connection()
return self.__nfs_client_connection

@retry((TimeoutError, socket.gaierror), tries=10, delay=60, backoff=1)
def get_nfs_client_connection(self):
def get_nfs_client_connection(self, re_try=True):
"""
Create connection to NFS Client VM.
"""
log.info("Login to test vm")
return Connection(
self.nfs_client_ip,
self.nfs_client_user,
private_key=self.nfs_client_private_key,
)
log.info("Connecting to nfs client test VM")
tries = 3 if re_try else 1

@retry((TimeoutError, socket.gaierror), tries=tries, delay=60, backoff=1)
def __make_connection():
return Connection(
self.nfs_client_ip,
self.nfs_client_user,
private_key=self.nfs_client_private_key,
)

return __make_connection()

@tier1
@polarion_id("OCS-4269")
Expand Down

0 comments on commit 786b52d

Please sign in to comment.