From d696a8ee687dce052a50ee71cbc20923eeae3210 Mon Sep 17 00:00:00 2001 From: anastasia prasolova Date: Wed, 1 Jun 2022 01:17:40 +0300 Subject: [PATCH] do not catch error in HEAD as we need it fails on empty response Signed-off-by: anastasia prasolova --- .../lib/python_keywords/neofs_verbs.py | 8 +---- .../lib/python_keywords/storage_policy.py | 29 ++++++++++++------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/robot/resources/lib/python_keywords/neofs_verbs.py b/robot/resources/lib/python_keywords/neofs_verbs.py index ba0236c6..d1a17055 100644 --- a/robot/resources/lib/python_keywords/neofs_verbs.py +++ b/robot/resources/lib/python_keywords/neofs_verbs.py @@ -247,13 +247,7 @@ def head_object(wallet: str, cid: str, oid: str, bearer_token: str="", f'{"--raw" if is_raw else ""} ' f'{"--ttl 1" if is_direct else ""}' ) - output = None - try: - output = _cmd_run(cmd) - except Exception as exc: - logger.info(f"Head request failed with output: {output}") - return None - + output = _cmd_run(cmd) if not json_output: return output diff --git a/robot/resources/lib/python_keywords/storage_policy.py b/robot/resources/lib/python_keywords/storage_policy.py index 8ae7ead3..dd8afd7a 100644 --- a/robot/resources/lib/python_keywords/storage_policy.py +++ b/robot/resources/lib/python_keywords/storage_policy.py @@ -10,6 +10,7 @@ import complex_object_actions import neofs_verbs from robot.api.deco import keyword +from robot.api import logger ROBOT_AUTO_KEYWORDS = False @@ -51,11 +52,15 @@ def get_simple_object_copies(wallet: str, cid: str, oid: str): """ copies = 0 for node in NEOFS_NETMAP: - response = neofs_verbs.head_object(wallet, cid, oid, - endpoint=node, - is_direct=True) - if response: - copies += 1 + try: + response = neofs_verbs.head_object(wallet, cid, oid, + endpoint=node, + is_direct=True) + if response: + copies += 1 + except Exception as exc: + logger.info(f"No {oid} object copy found on {node}, continue") + continue return copies @@ -94,11 +99,15 @@ def get_nodes_with_object(wallet: str, cid: str, oid: str): """ nodes_list = [] for node in NEOFS_NETMAP: - res = neofs_verbs.head_object(wallet, cid, oid, - endpoint=node, - is_direct=True) - if res is not None: - nodes_list.append(node) + try: + res = neofs_verbs.head_object(wallet, cid, oid, + endpoint=node, + is_direct=True) + if res is not None: + nodes_list.append(node) + except Exception as exc: + logger.info(f"No {oid} object copy found on {node}, continue") + continue return nodes_list