diff --git a/artifacts_test.py b/artifacts_test.py index 8bf0299af3c..e9471b931c9 100644 --- a/artifacts_test.py +++ b/artifacts_test.py @@ -466,7 +466,7 @@ def get_email_data(self): email_data = self._get_common_email_data() try: node = self.node - except Exception: # pylint: disable=broad-except + except (ValueError, IndexError): node = None if node: scylla_packages = node.scylla_packages_installed diff --git a/docker/alternator-dns/dns_server.py b/docker/alternator-dns/dns_server.py index e90d3b11a0b..8f52d0757ab 100644 --- a/docker/alternator-dns/dns_server.py +++ b/docker/alternator-dns/dns_server.py @@ -34,7 +34,7 @@ def livenodes_update(): # If we're successful, replace livenodes by the new list livenodes = a print(livenodes) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 # TODO: contacting this ip was unsuccessful, maybe we should # remove it from the list of live nodes. pass diff --git a/functional_tests/scylla_operator/conftest.py b/functional_tests/scylla_operator/conftest.py index 170b18756af..0735021d021 100644 --- a/functional_tests/scylla_operator/conftest.py +++ b/functional_tests/scylla_operator/conftest.py @@ -175,7 +175,7 @@ def _bring_cluster_back_to_original_state( db_cluster.restart_scylla() db_cluster.wait_for_nodes_up_and_normal( nodes=db_cluster.nodes, verification_node=db_cluster.nodes[0]) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 tester.healthy_flag = False pytest.fail("Failed to bring cluster nodes back to original state due to :\n" + "".join(traceback.format_exception(type(exc), exc, exc.__traceback__))) diff --git a/functional_tests/scylla_operator/test_functional.py b/functional_tests/scylla_operator/test_functional.py index 1a18d465541..a43e98b02dd 100644 --- a/functional_tests/scylla_operator/test_functional.py +++ b/functional_tests/scylla_operator/test_functional.py @@ -322,7 +322,7 @@ def wait_for_cleanup_logs(log_follower_name, log_follower, db_cluster): time.sleep(4) db_cluster.nodes[0].run_cqlsh(cmd=f"DROP KEYSPACE IF EXISTS {current_ks_name}", timeout=60) time.sleep(4) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 # NOTE: we don't care if some of the queries fail. # At first, there are redundant ones and, at second, they are utilitary. log.warning("Utilitary CQL query has failed: %s", exc) @@ -646,7 +646,7 @@ def change_cluster_spec() -> None: # NOTE: increase the value only when the sysctl spec update is successful # to avoid false negative results in further assertions expected_aio_max_nr_value += 1 - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 str_error = str(error) log.debug("Change /spec/sysctls value to %d failed. Error: %s", expected_aio_max_nr_value, str_error) diff --git a/longevity_test.py b/longevity_test.py index 29e7fe2dcfa..43d2d0982da 100644 --- a/longevity_test.py +++ b/longevity_test.py @@ -464,13 +464,9 @@ def _flush_all_nodes(self): def get_email_data(self): self.log.info("Prepare data for email") - email_data = {} grafana_dataset = {} - try: - email_data = self._get_common_email_data() - except Exception as error: # pylint: disable=broad-except - self.log.exception("Error in gathering common email data: Error:\n%s", error, exc_info=error) + email_data = self._get_common_email_data() try: grafana_dataset = self.monitors.get_grafana_screenshot_and_snapshot( diff --git a/performance_regression_test.py b/performance_regression_test.py index 4414a81f762..b0e9049f3ac 100644 --- a/performance_regression_test.py +++ b/performance_regression_test.py @@ -176,7 +176,7 @@ def display_results(self, results, test_name=''): with open(os.path.join(self.logdir, 'jenkins_perf_PerfPublisher.xml'), 'w', encoding="utf-8") as pref_file: content = """%s""" % (test_name, test_xml) pref_file.write(content) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 self.log.debug('Failed to display results: {0}'.format(results)) self.log.debug('Exception: {0}'.format(ex)) diff --git a/pyproject.toml b/pyproject.toml index 03f711db2fe..a1f2bddf56f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.ruff] -lint.select = ["PL"] +lint.select = ["PL", "YTT", "BLE"] lint.ignore = ["E501", "PLR2004"] diff --git a/sct.py b/sct.py index d3ae8a93be6..6decfa6ed3b 100755 --- a/sct.py +++ b/sct.py @@ -795,7 +795,7 @@ def _run_yaml_test(backend, full_path, env): config = SCTConfiguration() config.verify_configuration() config.check_required_files() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 output.append(''.join(traceback.format_exception(type(exc), exc, exc.__traceback__))) error = True return error, output @@ -815,7 +815,7 @@ def lint_yamls(backend, exclude: str, include: str): # pylint: disable=too-many continue try: exclude_filters.append(re.compile(flt)) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 raise ValueError(f'Exclude filter "{flt}" compiling failed with: {exc}') from exc include_filters = [] @@ -824,7 +824,7 @@ def lint_yamls(backend, exclude: str, include: str): # pylint: disable=too-many continue try: include_filters.append(re.compile(flt)) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 raise ValueError(f'Include filter "{flt}" compiling failed with: {exc}') from exc original_env = {**os.environ} @@ -965,7 +965,7 @@ def show_monitor(test_id, date_time, kill, cluster_name): containers = {} try: containers = restore_monitoring_stack(test_id, date_time) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error(details) if not containers: @@ -1348,7 +1348,7 @@ def send_email(test_id=None, test_status=None, start_time=None, started_by=None, sys.exit(1) try: reporter.send_report(test_results) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Failed to create email due to the following error:\n%s", traceback.format_exc()) build_reporter("TestAborted", email_recipients, testrun_dir).send_report({ "job_url": os.environ.get("BUILD_URL"), diff --git a/sdcm/cassandra_harry_thread.py b/sdcm/cassandra_harry_thread.py index a341962b9f4..34e30fe3365 100644 --- a/sdcm/cassandra_harry_thread.py +++ b/sdcm/cassandra_harry_thread.py @@ -103,7 +103,7 @@ def _run_stress(self, loader, loader_idx, cpu_idx): retry=0, ) result = self._parse_harry_summary(docker_run_result.stdout.splitlines()) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 errors_str = format_stress_cmd_error(exc) if "timeout" in errors_str: event_type = CassandraHarryEvent.timeout diff --git a/sdcm/cdclog_reader_thread.py b/sdcm/cdclog_reader_thread.py index 1a309b8da66..b901b36505e 100644 --- a/sdcm/cdclog_reader_thread.py +++ b/sdcm/cdclog_reader_thread.py @@ -79,7 +79,7 @@ def _run_stress(self, loader, loader_idx, cpu_idx): # pylint: disable=unused-ar stress_cmd=self.stress_cmd, errors=result.stderr.split("\n")).publish() return result - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 CDCReaderStressEvent.failure(node=loader, stress_cmd=self.stress_cmd, errors=[format_stress_cmd_error(exc), ]).publish() diff --git a/sdcm/cluster.py b/sdcm/cluster.py index ab85fea0203..2e706098263 100644 --- a/sdcm/cluster.py +++ b/sdcm/cluster.py @@ -542,7 +542,7 @@ def short_hostname(self): if not self._short_hostname: try: self._short_hostname = self.remoter.run('hostname -s').stdout.strip() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 return "no_booted_yet" return self._short_hostname @@ -588,7 +588,7 @@ def cpu_cores(self) -> Optional[int]: try: result = self.remoter.run("nproc", ignore_status=True) return int(result.stdout) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Failed to get number of cores due to the %s", details) return None @@ -604,7 +604,7 @@ def scylla_shards(self) -> int: shards = self.smp or self.cpuset or self.cpu_cores try: return int(shards) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Failed to convert to integer shards value: %s", shards) return 0 @@ -630,7 +630,7 @@ def cpuset(self): # 'CPUSET="--cpuset 1-7,9-15,17-23,25-31 "' # And so on... cpuset_file_lines = self.remoter.run("cat /etc/scylla.d/cpuset.conf").stdout - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error(f"Failed to get CPUSET. Error: {exc}") return '' @@ -668,7 +668,7 @@ def smp(self): try: grep_result = self.remoter.sudo(f'grep "^SCYLLA_ARGS=" {self.scylla_server_sysconfig_path}') - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error(f"Failed to get SCYLLA_ARGS. Error: {exc}") return '' @@ -713,7 +713,7 @@ def extract_seeds_from_scylla_yaml(self): try: node_seeds = conf_dict['seed_provider'][0]['parameters'][0].get('seeds') - except Exception as details: + except Exception as details: # noqa: BLE001 self.log.debug('Loaded YAML data structure: %s', conf_dict) raise ValueError('Exception determining seed node ips') from details @@ -747,7 +747,7 @@ def scylla_pkg(self): def file_exists(self, file_path: str) -> Optional[bool]: try: return self.remoter.sudo(f"test -e '{file_path}'", ignore_status=True).ok - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Error checking if file %s exists: %s", file_path, details) return None @@ -1026,7 +1026,7 @@ def hard_reboot(self): # pylint: disable=no-self-use def soft_reboot(self): # pylint: disable=no-self-use try: self.remoter.run('sudo reboot', ignore_status=True, retry=0) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass def restart_binary_protocol(self, verify_up=True): @@ -1069,7 +1069,7 @@ def uptime_changed(): except SSHException as ex: self.log.debug("Network isn't available, reboot might already start, %s" % ex) return False - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 self.log.debug('Failed to get uptime during reboot, %s' % ex) return False @@ -1185,7 +1185,7 @@ def get_installed_packages(self): try: result = self.remoter.run(cmd, verbose=False) return result.stdout.strip() - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.error('Error retrieving installed packages: %s', details) return None @@ -1215,7 +1215,7 @@ def is_port_used(self, port: int, service_name: str) -> bool: else: self.log.error("Error checking for '%s' on port %s: rc: %s", service_name, port, result) return False - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Error checking for '%s' on port %s: %s", service_name, port, details) return False @@ -1332,7 +1332,7 @@ def _report_housekeeping_uuid(self): if self.uuid and not mark_exists: self.remoter.run(cmd % self.uuid, ignore_status=True) self.remoter.sudo('touch %s' % mark_path, verbose=False, user='scylla') - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.error('Failed to report housekeeping uuid. Error details: %s', details) def wait_db_up(self, verbose=True, timeout=3600): @@ -1497,7 +1497,7 @@ def decode_backtrace(self): event.backtrace = output.stdout except queue.Empty: pass - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.error("failed to decode backtrace %s", details) finally: if event: @@ -1893,7 +1893,7 @@ def update_repo_cache(self): self.remoter.sudo('apt-get clean all') self.remoter.sudo('rm -rf /var/cache/apt/') self.remoter.sudo('apt-get update', retry=3) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 self.log.error('Failed to update repo cache: %s', ex) def upgrade_system(self): @@ -2241,7 +2241,7 @@ def install_mgmt(self, package_url: Optional[str] = None) -> None: if self.is_docker(): try: self.remoter.run("echo no | sudo scyllamgr_setup") - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 self.log.warning(ex) else: self.remoter.run("echo yes | sudo scyllamgr_setup") @@ -2392,7 +2392,7 @@ def stop_scylla_server(self, verify_up=False, verify_down=True, timeout=300, ign self.wait_db_up(timeout=timeout) try: self.stop_service(service_name='scylla-server', timeout=timeout, ignore_status=ignore_status) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 if isinstance(details, RetryableNetworkException): details = details.original if details.__class__.__name__.endswith("CommandTimedOut"): @@ -2582,7 +2582,7 @@ def run_nodetool(self, sub_cmd: str, args: str = "", options: str = "", timeout: nodetool_event.duration = result.duration return result - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 if isinstance(details, RetryableNetworkException): details = details.original if coredump_on_timeout and details.__class__.__name__.endswith("CommandTimedOut"): @@ -2669,7 +2669,7 @@ def get_nodes_status(self) -> dict[BaseNode, dict]: if node_ip: LOGGER.error("Get nodes statuses. Failed to find a node in cluster by IP: %s", node_ip) - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 ClusterHealthValidatorEvent.NodeStatus( severity=Severity.WARNING, node=self.name, @@ -2802,7 +2802,7 @@ def run_cqlsh(self, cmd, keyspace=None, timeout=120, verbose=True, split=False, cqlsh_out = self.remoter.run(cmd, timeout=timeout + 120, # we give 30 seconds to cqlsh timeout mechanism to work verbose=verbose) break - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 num_retry_on_failure -= 1 if not num_retry_on_failure: raise @@ -2872,7 +2872,7 @@ def get_scylla_config_param(self, config_param_name, verbose=True): if verbose: self.log.debug(f'{config_param_name} parameter value: {request_out.stdout}') return request_out.stdout - except Exception as e: # pylint: disable=broad-except + except Exception as e: # pylint: disable=broad-except # noqa: BLE001 self.log.error(f'Failed to retreive value of {config_param_name} parameter. Error: {e}') return None @@ -3045,7 +3045,7 @@ def get_token_ring_members(self) -> list[dict[str, str]]: return [] try: result_json = json.loads(result.stdout) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.warning("Error getting token-ring data: %s", exc) return [] @@ -3617,7 +3617,7 @@ def execute_cmd(cql_session, entity_type): publish_event=False, retry=3) cf_stats = db_node._parse_cfstats(res.stdout) # pylint: disable=protected-access has_data = bool(cf_stats['Number of partitions (estimate)']) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.warning(f'Failed to get rows from {table_name} table. Error: {exc}') if not has_data: @@ -3645,7 +3645,7 @@ def is_table_has_data(self, session, table_name: str) -> (bool, Optional[Excepti result = session.execute(SimpleStatement(f"SELECT * FROM {table_name}", fetch_size=10)) return result and bool(len(result.one())), None - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.warning(f'Failed to get rows from {table_name} table. Error: {exc}') return False, exc @@ -3769,13 +3769,13 @@ def node_setup(_node: BaseNode, task_queue: queue.Queue): exception_details = None try: cl_inst.node_setup(_node, **setup_kwargs) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 exception_details = (str(ex), traceback.format_exc()) try: _node.update_shards_in_argus() LOGGER.info("DC: %s | Rack: %s", _node.datacenter, _node.node_rack) _node.update_rack_info_in_argus(_node.datacenter, _node.node_rack) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Failure settings shards for node %s in Argus.", _node) LOGGER.debug("Exception details:\n", exc_info=True) task_queue.put((_node, exception_details)) @@ -3786,7 +3786,7 @@ def node_startup(_node: BaseNode, task_queue: queue.Queue): exception_details = None try: cl_inst.node_startup(_node, **setup_kwargs) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 exception_details = (str(ex), traceback.format_exc()) task_queue.put((_node, exception_details)) task_queue.task_done() @@ -3861,7 +3861,7 @@ def critical_node_setup_events(): for node in node_list: try: node.update_rack_info_in_argus(node.datacenter, node.node_rack) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Failure settings dc/rack infomration for %s in Argus.", node) LOGGER.debug("Exception details:\n", exc_info=True) @@ -4441,7 +4441,7 @@ def _rotate_kms_key(kms_key_alias_name, kms_key_rotation_interval, db_cluster): time.sleep(kms_key_rotation_interval * 60) try: aws_kms.rotate_kms_key(kms_key_alias_name=kms_key_alias_name) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 AwsKmsEvent( message=f"Failed to rotate AWS KMS key for the '{kms_key_alias_name}' alias", traceback=traceback.format_exc()).publish() @@ -4475,7 +4475,7 @@ def _rotate_kms_key(kms_key_alias_name, kms_key_rotation_interval, db_cluster): AwsKmsEvent( message="Failed to get any table for the KMS key rotation thread", traceback=traceback.format_exc()).publish() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 AwsKmsEvent( message="Failed to check the fact of encryption (KMS) for sstables", traceback=traceback.format_exc()).publish() @@ -4655,7 +4655,7 @@ def _scylla_install(self, node): install_mode = self.params.get('install_mode') try: mode = InstallMode(install_mode) - except Exception as ex: + except Exception as ex: # noqa: BLE001 raise ValueError(f'Invalid install mode: {install_mode}, err: {ex}') from ex if mode == InstallMode.WEB: @@ -4819,7 +4819,7 @@ def get_node_ip_list(verification_node): for nodes_ips in status.values(): ip_node_list.extend(nodes_ips.keys()) return ip_node_list - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error(str(details)) return None @@ -4962,7 +4962,7 @@ def gemini_version(self): f'gemini --version', ignore_status=True) if result.ok: self._gemini_version = get_gemini_version(result.stdout) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Error get gemini version: %s", details) return self._gemini_version @@ -5083,7 +5083,7 @@ def kill_cs_process(loader, filter_cmd): wait.wait_for(kill_cs_process, text="Search and kill c-s processes", timeout=30, throw_exc=False, loader=loader, filter_cmd=search_cmd) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 self.log.warning("failed to kill stress-command on [%s]: [%s]", str(loader), str(ex)) @@ -5092,7 +5092,7 @@ def kill_docker_loaders(self): try: loader.remoter.run(cmd='docker ps -a -q | xargs docker rm -f', verbose=True, ignore_status=True) self.log.info("Killed docker loader on node: %s", loader.name) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 self.log.warning("failed to kill docker stress command on [%s]: [%s]", str(loader), str(ex)) @@ -5666,7 +5666,7 @@ def get_grafana_annotations(self, node): grafana_port=self.grafana_port)) if res.ok: return res.content - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("unable to get grafana annotations [%s]", str(ex)) return "" @@ -5741,7 +5741,7 @@ def download_monitor_data(self) -> str: if snapshot_archive := PrometheusSnapshots(name='prometheus_snapshot').collect(self.nodes[0], self.logdir): self.log.debug("Snapshot local path: %s", snapshot_archive) return upload_archive_to_s3(snapshot_archive, self.monitor_id) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Error downloading prometheus data dir: %s", details) return "" diff --git a/sdcm/cluster_aws.py b/sdcm/cluster_aws.py index 142cdd2fb43..437140df9b6 100644 --- a/sdcm/cluster_aws.py +++ b/sdcm/cluster_aws.py @@ -551,7 +551,7 @@ def check_spot_termination(self): result = self.remoter.run( 'curl http://169.254.169.254/latest/meta-data/spot/instance-action', verbose=False) status = result.stdout.strip() - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.warning('Error during getting spot termination notification %s', details) return 0 @@ -966,7 +966,7 @@ def get_seed_nodes(self): conf_dict = yaml.safe_load(yaml_stream) try: return conf_dict['seed_provider'][0]['parameters'][0]['seeds'].split(',') - except Exception as exc: + except Exception as exc: # noqa: BLE001 raise ValueError('Unexpected cassandra.yaml. Contents:\n%s' % yaml_stream.read()) from exc # pylint: disable=too-many-arguments diff --git a/sdcm/cluster_azure.py b/sdcm/cluster_azure.py index bf141a41c04..d85ba9b32f1 100644 --- a/sdcm/cluster_azure.py +++ b/sdcm/cluster_azure.py @@ -122,7 +122,7 @@ def check_spot_termination(self): else: # other EventType's that can be triggered by Azure's maintenance: "Reboot" | "Redeploy" | "Freeze" | "Terminate" self.log.warning(f"Unhandled Azure scheduled event: {event}") - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.warning('Error during getting Azure scheduled events: %s', details) return 0 return SPOT_TERMINATION_CHECK_DELAY @@ -227,7 +227,7 @@ def _create_node(self, instance, node_index, dc_idx, rack): rack=rack) node.init() return node - except Exception as ex: + except Exception as ex: # noqa: BLE001 raise CreateAzureNodeError('Failed to create node: %s' % ex) from ex def _create_instances(self, count, dc_idx=0, instance_type=None) -> List[VmInstance]: diff --git a/sdcm/cluster_docker.py b/sdcm/cluster_docker.py index 89c3e5d00b1..6c2582eb600 100644 --- a/sdcm/cluster_docker.py +++ b/sdcm/cluster_docker.py @@ -488,11 +488,11 @@ def destroy(self): try: self.stop_scylla_monitoring(node) self.log.error("Stopping scylla monitoring succeeded") - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error(f"Stopping scylla monitoring failed with {str(exc)}") try: node.remoter.sudo(f"rm -rf '{self.monitor_install_path_base}'") self.log.error("Cleaning up scylla monitoring succeeded") - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error(f"Cleaning up scylla monitoring failed with {str(exc)}") node.destroy() diff --git a/sdcm/cluster_gce.py b/sdcm/cluster_gce.py index a59fa4d4dce..692d9c4a688 100644 --- a/sdcm/cluster_gce.py +++ b/sdcm/cluster_gce.py @@ -183,7 +183,7 @@ def check_spot_termination(self): GceInstanceEvent(entry).publish() case _: GceInstanceEvent(entry, severity=Severity.WARNING).publish() - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.warning('Error during getting spot termination notification %s', details) self._last_logs_fetch_time = since return SPOT_TERMINATION_CHECK_DELAY @@ -500,7 +500,7 @@ def _create_node(self, instance, node_index, dc_idx, rack): rack=rack) node.init() return node - except Exception as ex: + except Exception as ex: # noqa: BLE001 raise CreateGCENodeError('Failed to create node: %s' % ex) from ex # pylint: disable=too-many-arguments diff --git a/sdcm/cluster_k8s/__init__.py b/sdcm/cluster_k8s/__init__.py index d4100763535..1db7c079750 100644 --- a/sdcm/cluster_k8s/__init__.py +++ b/sdcm/cluster_k8s/__init__.py @@ -249,7 +249,7 @@ def readiness_timeout(self) -> int: def nodes(self): try: return self.k8s_cluster.k8s_core_v1_api.list_node(label_selector=f'{self.pool_label_name}={self.name}') - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.k8s_cluster.log.debug("Failed to get nodes list: %s", str(details)) return {} @@ -822,7 +822,7 @@ def upgrade_scylla_operator(self, new_helm_repo: str, continue self.apply_file( os.path.join(crd_basedir, current_file), modifiers=[], envsubst=False) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.debug("Upgrade Scylla Operator CRDs: Exception: %s", exc) self.log.info("Upgrade Scylla Operator CRDs: END") @@ -1270,7 +1270,7 @@ def deploy_scylla_cluster(self, node_pool_name: str, namespace: str = SCYLLA_NAM self.kubectl("get scyllaclusters.scylla.scylladb.com", namespace=namespace) self.start_scylla_cluster_events_thread() return - except Exception as exc: + except Exception as exc: # noqa: BLE001 raise RuntimeError( "SCT_REUSE_CLUSTER is set, but target scylla cluster is unhealthy") from exc @@ -1665,7 +1665,7 @@ def scylla_config_map(self, namespace: str = SCYLLA_NAMESPACE) -> dict: config_map = self.k8s_core_v1_api.read_namespaced_config_map( name=SCYLLA_CONFIG_NAME, namespace=namespace).data or {} exists = True - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 config_map = {} exists = False original_config_map = deepcopy(config_map) @@ -1902,7 +1902,7 @@ def _refresh_instance_state(self): def k8s_pod_uid(self) -> str: try: return str(self._pod.metadata.uid) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 return '' @property @@ -2166,7 +2166,7 @@ def _restart_node_with_resharding(self, murmur3_partitioner_ignore_msb_bits: int def is_seed(self) -> bool: try: return 'scylla/seed' in self._svc.metadata.labels - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 return False @is_seed.setter @@ -2958,7 +2958,7 @@ def check_kubernetes_monitoring_health(self) -> bool: cluster_name=self.scylla_cluster_name, namespace=self.namespace) PrometheusDBStats(host=prometheus_ip, port=k8s_cluster.prometheus_port, protocol='https') kmh_event.message = "Kubernetes monitoring health checks have successfully been finished" - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 ClusterHealthValidatorEvent.MonitoringStatus( error=f'Failed to connect to K8S prometheus server (namespace={self.namespace}) at ' f'{prometheus_ip}:{k8s_cluster.prometheus_port}, due to the: \n' diff --git a/sdcm/cluster_k8s/eks.py b/sdcm/cluster_k8s/eks.py index 3e611c4271c..178117730da 100644 --- a/sdcm/cluster_k8s/eks.py +++ b/sdcm/cluster_k8s/eks.py @@ -312,7 +312,7 @@ def undeploy(self): self.k8s_cluster.eks_client.delete_nodegroup( clusterName=self.k8s_cluster.short_cluster_name, nodegroupName=self.name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.k8s_cluster.log.debug( "Failed to delete nodegroup %s/%s, due to the following error:\n%s", self.k8s_cluster.short_cluster_name, self.name, exc) diff --git a/sdcm/cluster_k8s/gke.py b/sdcm/cluster_k8s/gke.py index 9690fd81b4d..566a67b50a2 100644 --- a/sdcm/cluster_k8s/gke.py +++ b/sdcm/cluster_k8s/gke.py @@ -231,7 +231,7 @@ def instance_group_name(self) -> str: f'--cluster {self.k8s_cluster.short_cluster_name}') ).get('instanceGroupUrls')[0] return group_link.split('/')[-1] - except Exception as exc: + except Exception as exc: # noqa: BLE001 raise RuntimeError(f"Can't get instance group name due to the: {exc}") from exc def remove_instance(self, instance_name: str): diff --git a/sdcm/cluster_k8s/mini_k8s.py b/sdcm/cluster_k8s/mini_k8s.py index 32f40315937..fe6cc6b5403 100644 --- a/sdcm/cluster_k8s/mini_k8s.py +++ b/sdcm/cluster_k8s/mini_k8s.py @@ -345,7 +345,7 @@ def static_local_volume_provisioner_image(self): continue try: return doc["spec"]["template"]["spec"]["containers"][0]["image"] - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.warning( "Could not read the static local volume provisioner image: %s", exc) return "" @@ -377,7 +377,7 @@ def ingress_controller_images(self): for container in doc["spec"]["template"]["spec"]["containers"]: try: ingress_images.add(container["image"]) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.warning( "Could not read the ingress controller related image: %s", exc) return ingress_images @@ -688,7 +688,7 @@ def gather_k8s_logs(self) -> None: f"docker cp kind-control-plane:{src_container_path} {self.logdir} " f"&& mkdir -p {self.logdir}/{dst_subdir} " f"&& mv {self.logdir}/*/{log_prefix}* {self.logdir}/{dst_subdir}") - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.warning( "Failed to copy K8S apiserver audit logs located at '%s'. Exception: \n%s", src_container_path, exc) diff --git a/sdcm/commit_log_check_thread.py b/sdcm/commit_log_check_thread.py index b39369c1608..6a2ee64195e 100644 --- a/sdcm/commit_log_check_thread.py +++ b/sdcm/commit_log_check_thread.py @@ -174,7 +174,7 @@ def run_thread(self): self.zero_free_segments_checker(self.start_time, interval_end_time) self.start_time = interval_end_time - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 trace = traceback.format_exc() CommitLogCheckErrorEvent( message=f"CommitLogCheckThread failed: {exc.__repr__()} with traceback {trace}").publish() @@ -234,7 +234,7 @@ def run(custer_tester, duration): try: thread = CommitLogCheckThread(custer_tester, duration) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 trace = traceback.format_exc() CommitLogCheckErrorEvent( message=f"CommitLogCheckThread.__init__ failed with unexpected exception:" @@ -242,7 +242,7 @@ def run(custer_tester, duration): else: try: thread.start() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 trace = traceback.format_exc() CommitLogCheckErrorEvent( message=f"CommitLogCheckThread.start failed with unexpected exception:" diff --git a/sdcm/coredump.py b/sdcm/coredump.py index a16bd5e3efe..4b9d8bbc5e6 100644 --- a/sdcm/coredump.py +++ b/sdcm/coredump.py @@ -114,7 +114,7 @@ def run(self): try: self.main_cycle_body() exceptions_count = 0 - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Following error occurred: %s", exc) exceptions_count += 1 if exceptions_count == self.max_coredump_thread_exceptions: @@ -172,7 +172,7 @@ def _process_coredumps( if result: uploaded.append(core_info) self.publish_event(core_info) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass @abstractmethod @@ -182,7 +182,7 @@ def get_list_of_cores(self) -> Optional[List[CoreDumpInfo]]: def publish_event(self, core_info: CoreDumpInfo): try: core_info.publish_event() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error(f"Failed to publish coredump event due to the: {str(exc)}") def extract_info_from_core_pids( @@ -261,7 +261,7 @@ def _pack_coredump(self, coredump: str) -> str: coredump += '.gz' except NETWORK_EXCEPTIONS: # pylint: disable=try-except-raise raise - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 self.log.warning("Failed to compress coredump '%s': %s", coredump, ex) return coredump @@ -295,7 +295,7 @@ def systemd_version(self): try: systemd_version = get_systemd_version(self.node.remoter.run( "systemctl --version", ignore_status=True).stdout) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 self.log.warning("failed to get systemd version:", exc_info=True) return systemd_version @@ -430,7 +430,7 @@ def update_coredump_info_with_more_information(self, core_info: CoreDumpInfo): else: raise ValueError(f'Date has unknown format: {timestring}') event_timestamp = datetime.strptime(timestring, fmt).timestamp() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error(f"Failed to convert date '{line}' ({timestring}), due to error: {str(exc)}") core_info.update(executable=executable, command_line=command_line, corefile=corefile, source_timestamp=event_timestamp, coredump_info="\n".join(coredump_info)+"\n") diff --git a/sdcm/cql_stress_cassandra_stress_thread.py b/sdcm/cql_stress_cassandra_stress_thread.py index 59d801d417b..d1b6b4d9b5b 100644 --- a/sdcm/cql_stress_cassandra_stress_thread.py +++ b/sdcm/cql_stress_cassandra_stress_thread.py @@ -157,7 +157,7 @@ def _run_cs_stress(self, loader, loader_idx, cpu_idx, keyspace_idx): # pylint: with SoftTimeoutContext(timeout=self.timeout, operation="cql-stress-cassandra-stress"): result = cmd_runner.run( cmd=node_cmd, timeout=hard_timeout, log_file=log_file_name, retry=0) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.configure_event_on_failure( stress_event=cs_stress_event, exc=exc) diff --git a/sdcm/db_log_reader.py b/sdcm/db_log_reader.py index 8a145ebb6c4..69eb72c1bde 100644 --- a/sdcm/db_log_reader.py +++ b/sdcm/db_log_reader.py @@ -111,7 +111,7 @@ def _read_and_publish_events(self) -> None: # noqa: PLR0912 if line[0] == '{': try: json_log = json.loads(line) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass if self._log_lines: diff --git a/sdcm/db_stats.py b/sdcm/db_stats.py index c974cf12a1d..2e47808b3fc 100644 --- a/sdcm/db_stats.py +++ b/sdcm/db_stats.py @@ -126,7 +126,7 @@ def get_stress_cmd_params(cmd): del cmd_params['rate'] return cmd_params - except Exception as ex: + except Exception as ex: # noqa: BLE001 raise CassandraStressCmdParseError(cmd=cmd, ex=ex) from None @@ -349,7 +349,7 @@ def get_scylla_scheduler_shares_per_sla(self, start_time, end_time, node_ip): # for item in results: try: res[item['metric']['group']] = {int(i[1]) for i in item['values']} - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 # average value may be returned not integer. Ignore it LOGGER.error("Failed to analyze results of query: %s\nResults: %s\nError: %s", query, results, error) return res @@ -727,7 +727,7 @@ def _calc_stats(self, ps_results): stat["stdev"] = stddev(ops_filtered) self.log.debug("Stats: %s", stat) return stat - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Exception when calculating PrometheusDB stats: %s" % ex) return {} @@ -773,7 +773,7 @@ def _convert_stat(self, stat, stress_result): return 0 try: return float(stress_result[stat]) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.warning("Error in conversion of '%s' for stat '%s': '%s'" "Discarding stat." % (stress_result[stat], stat, details)) return 0 diff --git a/sdcm/fill_db_data.py b/sdcm/fill_db_data.py index 22fd951f8b2..def7fcefdd9 100644 --- a/sdcm/fill_db_data.py +++ b/sdcm/fill_db_data.py @@ -3327,7 +3327,7 @@ def fill_db_data(self): try: session.set_keyspace(self.base_ks) self.truncate_tables(session) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Found error in truncate tables: '%s'", ex) # Insert data to the tables according to the "inserts" and flush to disk in several cases (nodetool flush) diff --git a/sdcm/gemini_thread.py b/sdcm/gemini_thread.py index 6f91ba23f53..241e4d6dd7b 100644 --- a/sdcm/gemini_thread.py +++ b/sdcm/gemini_thread.py @@ -130,7 +130,7 @@ def _run_stress(self, loader, loader_idx, cpu_idx): ) # sleep to gather all latest log messages time.sleep(5) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error(details) result = getattr(details, "result", NotGeminiErrorResult(details)) @@ -187,7 +187,7 @@ def _parse_gemini_summary_json(json_str): try: results = json.loads(json_str) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Invalid json document {}".format(details)) return results.get('result') diff --git a/sdcm/logcollector.py b/sdcm/logcollector.py index d67d6baa97c..73a8825e3a8 100644 --- a/sdcm/logcollector.py +++ b/sdcm/logcollector.py @@ -150,7 +150,7 @@ def get_monitoring_version(self, node): return None, None, None result = node.remoter.run( f"cat {basedir}/{name}/monitor_version", ignore_status=True, verbose=False) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Failed to get monitoring version: %s", details) return None, None, None @@ -389,7 +389,7 @@ def get_grafana_annotations(self, grafana_ip: str) -> str: res = requests.get(f"http://{grafana_ip}:{self.grafana_port}/api/annotations") if res.ok: return res.text - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Unable to get Grafana annotations [%s]", details) return "" @@ -512,7 +512,7 @@ def get_grafana_screenshot(self, node, local_dst): return screenshots - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Error taking monitor screenshot: %s, traceback: %s", details, traceback.format_exc()) return [] @@ -578,7 +578,7 @@ def create_remote_storage_dir(self, node, path=''): 'Remote storing folder not created.\n{}'.format(result)) remote_dir = self.node_remote_dir - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Error during creating remote directory %s", details) remote_dir = self.node_remote_dir @@ -623,7 +623,7 @@ def collect_logs_per_node(node): for log_entity in self.log_entities: try: log_entity.collect(node, local_node_dir, remote_node_dir, local_search_path=local_search_path) - except Exception as details: # pylint: disable=unused-variable, broad-except + except Exception as details: # pylint: disable=unused-variable, broad-except # noqa: BLE001 LOGGER.error("Error occured during collecting on host: %s\n%s", node.name, details) LOGGER.debug("Nodes list %s", [node.name for node in self.nodes]) @@ -636,7 +636,7 @@ def collect_logs_per_node(node): try: ParallelObject(self.nodes, num_workers=workers_number, timeout=self.collect_timeout).run( collect_logs_per_node, ignore_exceptions=True) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error('Error occured during collecting logs %s', details) if not os.listdir(self.local_dir): @@ -686,7 +686,7 @@ def archive_to_tarfile(self, src_path: str, add_test_id_to_archive: bool = False src_name = src_name.replace(extension, f"-{self.test_id.split('-')[0]}{extension}") try: return self._compress_file(src_path, src_name) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Error during archive creation. Details: \n%s", details) return None @@ -770,7 +770,7 @@ def save_kallsyms_map(node): try: log_entity.collect(node, node.logdir, remote_node_dir) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Error occurred during collecting kallsyms on host: %s\n%s", node.name, details) @@ -797,7 +797,7 @@ def collect_log_entities(node, log_entities: List[BaseLogEntity]): try: log_entity.collect(node, node.logdir, remote_node_dir) LOGGER.debug("Diagnostic file '%s' collected", log_entity.name) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Error occurred during collecting diagnostics data on host: %s\n%s", node.name, details) @@ -1180,7 +1180,7 @@ def collect_logs(self, local_search_path: Optional[str] = None) -> list[str]: k8s_logdir, '.kube', current_k8s_logdir_sub_file)): KubernetesOps.gather_k8s_logs(k8s_logdir) break - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Got following failure processing the K8S logs: %s", exc) return super().collect_logs(local_search_path=local_search_path) @@ -1377,7 +1377,7 @@ def find_and_append_cloud_manager_instance_to_collecting_nodes(self): instance = get_manager_instance_by_cluster_id(cluster_id=cloud_cluster_id) if not instance: raise ValueError(f"Cloud manager for the cluster {cloud_cluster_id} not found") - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Failed to get cloud manager instance. Error: %s", exc) return diff --git a/sdcm/mgmt/cli.py b/sdcm/mgmt/cli.py index cfe9a8cd8de..5553132b6a3 100644 --- a/sdcm/mgmt/cli.py +++ b/sdcm/mgmt/cli.py @@ -1326,7 +1326,7 @@ def get(self, path, params=None): raise Exception(err_msg) try: return json.loads(resp.content) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error('Failed load data from json %s, error: %s', resp.content, ex) return resp.content diff --git a/sdcm/monitorstack/__init__.py b/sdcm/monitorstack/__init__.py index a4085701bf3..3480a844678 100644 --- a/sdcm/monitorstack/__init__.py +++ b/sdcm/monitorstack/__init__.py @@ -303,7 +303,7 @@ def get_monitoring_stack_scylla_version(monitoring_stack_dir): scylla_version = 'master' return monitoring_version, scylla_version - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 return 'branch-3.0', 'master' @@ -313,7 +313,7 @@ def restore_grafana_dashboards_and_annotations(monitoring_dockers_dir, grafana_d status.append(restore_sct_dashboards(grafana_docker_port=grafana_docker_port, sct_dashboard_file=sct_dashboard_file)) status.append(restore_annotations_data(monitoring_dockers_dir, grafana_docker_port=grafana_docker_port)) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Error during uploading sct monitoring data %s", details) status.append(False) @@ -323,7 +323,7 @@ def restore_grafana_dashboards_and_annotations(monitoring_dockers_dir, grafana_d def run_monitoring_stack_containers(monitoring_stack_dir, monitoring_data_dir, scylla_version, tenants_number=1): try: return start_dockers(monitoring_stack_dir, monitoring_data_dir, scylla_version, tenants_number) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Dockers are not started. Error: %s", details) return {} @@ -504,7 +504,7 @@ def verify_grafana_is_available(grafana_docker_port=GRAFANA_DOCKER_PORT): title=dashboard.title) grafana_statuses.append(result) LOGGER.info("Dashboard {} is available".format(dashboard.title)) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Dashboard %s is not available. Error: %s", dashboard.title, details) grafana_statuses.append(False) @@ -535,7 +535,7 @@ def verify_prometheus_is_available(prometheus_docker_port=PROMETHEUS_DOCKER_PORT prom_client.get_throughput(time_start, time_end) LOGGER.info("Prometheus is up") return True - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Error requesting prometheus %s", details) return False diff --git a/sdcm/ndbench_thread.py b/sdcm/ndbench_thread.py index 2ed87c8638f..1ae653c6efb 100644 --- a/sdcm/ndbench_thread.py +++ b/sdcm/ndbench_thread.py @@ -106,7 +106,7 @@ def run(self): operation, name = key.split('_', 1) self.set_metric(operation, name, float(value)) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Failed to send metric. Failed with exception {exc}".format(exc=exc)) @@ -155,7 +155,7 @@ def _run_stress(self, loader, loader_idx, cpu_idx): retry=0, ) return docker_run_result - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 NdBenchStressEvent.failure(node=str(loader), stress_cmd=self.stress_cmd, log_file_name=log_file_name, diff --git a/sdcm/nemesis.py b/sdcm/nemesis.py index 3a1d8339f2c..24028d4331d 100644 --- a/sdcm/nemesis.py +++ b/sdcm/nemesis.py @@ -594,7 +594,7 @@ def _get_subclasses_from_list( def __str__(self): try: return str(self.__class__).split("'")[1] - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 return str(self.__class__) def _kill_scylla_daemon(self): @@ -1022,7 +1022,7 @@ def replace_full_file_name_to_prefix(self, one_file, ks_cf_for_destroy): try: file_name_template = re.search(r"([^-]+-[^-]+)-", file_name).group(1) - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 self.log.debug('File name "{file_name}" is not as expected for Scylla data files. ' 'Search files for "{ks_cf_for_destroy}" table'.format(file_name=file_name, ks_cf_for_destroy=ks_cf_for_destroy)) @@ -2115,7 +2115,7 @@ def _add_drop_column_run_cql_query(self, cmd, ks, with self.cluster.cql_connection_patient(self.target_node, keyspace=ks) as session: session.default_consistency_level = consistency_level session.execute(cmd) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.debug(f"Add/Remove Column Nemesis: CQL query '{cmd}' execution has failed with error '{str(exc)}'") return False return True @@ -2224,7 +2224,7 @@ def choose_partitions_for_delete(self, partitions_amount, ks_cf, with_clustering cmd = f"select ck from {ks_cf} where pk={partition_key} order by ck desc limit 1" try: result = session.execute(SimpleStatement(cmd, fetch_size=1), timeout=300) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error(str(exc)) continue @@ -3224,7 +3224,7 @@ def get_ks_with_few_tables(keyspace_table): nodetool_cmd = snapshot_option[0]() if len(snapshot_option) == 1 else snapshot_option[0](snapshot_option[1]) if not nodetool_cmd: raise ValueError("Failed to get nodetool command.") - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 raise ValueError(f"Failed to get nodetool command. Error: {exc}") from exc self.log.debug(f'Take snapshot with command: {nodetool_cmd}') @@ -3491,7 +3491,7 @@ def remove_node(): for node in up_normal_nodes: try: self.repair_nodetool_repair(node=node, publish_event=False) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.error(f"failed to execute repair command " f"on node {node} due to the following error: {str(details)}") @@ -3713,7 +3713,7 @@ def _run_commands_wait_and_cleanup( # pylint: disable=too-many-arguments cmd_executed[cmd_num] = True if wait_time: time.sleep(wait_time) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 cmd_executed[cmd_num] = False self.log.error( f"{name}: failed to execute start command " @@ -3723,7 +3723,7 @@ def _run_commands_wait_and_cleanup( # pylint: disable=too-many-arguments for cmd_num, cmd in enumerate(cleanup_commands): try: node.remoter.run(cmd) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.debug(f"{name}: failed to execute cleanup command " f"{cmd} on node {node} due to the following error: {str(exc)}") @@ -3810,7 +3810,7 @@ def decommission_post_action(): except Group0MembersNotConsistentWithTokenRingMembersException as exc: self.log.error("Cluster state could be not predictable due to ghost members in raft group0: %s", exc) raise - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error('Unexpected exception raised in checking decommission status: %s', exc) self.log.info('Decommission might complete before stopping it. Re-add a new node') @@ -3994,7 +3994,7 @@ def decommission_nodes(self, add_nodes_number, rack, is_seed: Optional[Union[boo InfoEvent(f'StartEvent - ShrinkCluster started decommissioning a node {self.target_node}').publish() self.decommission_node(self.target_node) InfoEvent(f'FinishEvent - ShrinkCluster has done decommissioning a node {self.target_node}').publish() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 InfoEvent(f'FinishEvent - ShrinkCluster failed decommissioning a node {self.target_node} with error ' f'{str(exc)}').publish() @@ -5058,7 +5058,7 @@ def data_validation_prints(args): args[0].tester.data_validator.validate_range_not_expected_to_change(session, during_nemesis=True) args[0].tester.data_validator.validate_range_expected_to_change(session, during_nemesis=True) args[0].tester.data_validator.validate_deleted_rows(session, during_nemesis=True) - except Exception as err: # pylint: disable=broad-except + except Exception as err: # pylint: disable=broad-except # noqa: BLE001 args[0].log.debug(f'Data validator error: {err}') @wraps(method) @@ -5128,7 +5128,7 @@ def wrapper(*args, **kwargs): # pylint: disable=too-many-statements log_info.update({'subtype': 'skipped', 'skip_reason': skip_reason}) nemesis_event.skip(skip_reason=skip_reason) raise - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 nemesis_event.add_error([str(details)]) nemesis_event.full_traceback = traceback.format_exc() nemesis_event.severity = Severity.ERROR @@ -5157,7 +5157,7 @@ def wrapper(*args, **kwargs): # pylint: disable=too-many-statements except ElasticSearchConnectionTimeout as err: args[0].log.warning(f"Connection timed out when attempting to update elasticsearch statistics:\n" f"{err}") - except Exception as err: # pylint: disable=broad-except + except Exception as err: # pylint: disable=broad-except # noqa: BLE001 args[0].log.warning(f"Unexpected error when attempting to update elasticsearch statistics:\n" f"{err}") args[0].log.info(f"log_info: {log_info}") diff --git a/sdcm/nosql_thread.py b/sdcm/nosql_thread.py index 939429af6fa..be07056a611 100644 --- a/sdcm/nosql_thread.py +++ b/sdcm/nosql_thread.py @@ -111,6 +111,6 @@ def _run_stress(self, loader, loader_idx, cpu_idx): f'{self.docker_image_name} ' f'{stress_cmd} --report-graphite-to graphite-exporter:9109', timeout=self.timeout + self.shutdown_timeout, log_file=log_file_name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.configure_event_on_failure(stress_event=stress_event, exc=exc) return None diff --git a/sdcm/prometheus.py b/sdcm/prometheus.py index ee3a53840a4..5361540abd8 100644 --- a/sdcm/prometheus.py +++ b/sdcm/prometheus.py @@ -61,7 +61,7 @@ def start_metrics_server(): ip = get_my_ip() LOGGER.info('prometheus API server running on port: %s', port) return '{}:{}'.format(ip, port) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error('Cannot start local http metrics server: %s', ex) return None @@ -97,7 +97,7 @@ def __init__(self, metric_name_suffix=''): def create_counter(name, desc, param_list): try: return prometheus_client.Counter(name, desc, param_list) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error('Cannot create metrics counter: %s', ex) return None @@ -105,7 +105,7 @@ def create_counter(name, desc, param_list): def create_gauge(name, desc, param_list): try: return prometheus_client.Gauge(name, desc, param_list) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error('Cannot create metrics gauge: %s', ex) return None @@ -138,7 +138,7 @@ def __init__(self, ip, port=9093, interval=10, stop_flag: threading.Event = None def is_alert_manager_up(self): try: return requests.get(f"{self._alert_manager_url}/status", timeout=3).json()['cluster']['status'] == 'ready' - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 return False @log_run_info diff --git a/sdcm/provision/aws/capacity_reservation.py b/sdcm/provision/aws/capacity_reservation.py index 313e2c4859d..e6ddbc54025 100644 --- a/sdcm/provision/aws/capacity_reservation.py +++ b/sdcm/provision/aws/capacity_reservation.py @@ -210,7 +210,7 @@ def _create(ec2, test_id, availability_zone, instance_type, instance_count, dura **additional_params ) return response['CapacityReservation']['CapacityReservationId'] - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.info("Failed to create capacity reservation for %s. Error: %s", instance_type, exc) return None diff --git a/sdcm/provision/aws/provisioner.py b/sdcm/provision/aws/provisioner.py index b258479bcd9..0772f3bba17 100644 --- a/sdcm/provision/aws/provisioner.py +++ b/sdcm/provision/aws/provisioner.py @@ -208,7 +208,7 @@ def _get_provisioned_fleet_instance_ids( try: resp = self._ec2_client(provision_parameters).describe_spot_fleet_requests(SpotFleetRequestIds=request_ids) LOGGER.info("%s: - %s", request_ids, resp) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.info("%s: - failed to get status: %s", request_ids, exc) return [] for req in resp['SpotFleetRequestConfigs']: diff --git a/sdcm/provision/aws/utils.py b/sdcm/provision/aws/utils.py index 3adc80c3177..1ff5551a0d2 100644 --- a/sdcm/provision/aws/utils.py +++ b/sdcm/provision/aws/utils.py @@ -145,7 +145,7 @@ def wait_for_provision_request_done( def get_provisioned_fleet_instance_ids(region_name: str, request_ids: List[str]) -> Optional[List[str]]: try: resp = ec2_clients[region_name].describe_spot_fleet_requests(SpotFleetRequestIds=request_ids) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 return [] for req in resp['SpotFleetRequestConfigs']: if req['SpotFleetRequestState'] == 'active' and req.get('ActivityStatus', None) == STATUS_FULFILLED: @@ -168,7 +168,7 @@ def get_provisioned_fleet_instance_ids(region_name: str, request_ids: List[str]) for request_id in request_ids: try: resp = ec2_clients[region_name].describe_spot_fleet_instances(SpotFleetRequestId=request_id) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 return None provisioned_instances.extend([inst['InstanceId'] for inst in resp['ActiveInstances']]) return provisioned_instances @@ -182,7 +182,7 @@ def get_provisioned_spot_instance_ids(region_name: str, request_ids: List[str]) """ try: resp = ec2_clients[region_name].describe_spot_instance_requests(SpotInstanceRequestIds=request_ids) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 return [] provisioned = [] for req in resp['SpotInstanceRequests']: diff --git a/sdcm/remote/libssh2_client/__init__.py b/sdcm/remote/libssh2_client/__init__.py index 8bc7e8ed5ec..f23ef9a14f5 100644 --- a/sdcm/remote/libssh2_client/__init__.py +++ b/sdcm/remote/libssh2_client/__init__.py @@ -76,7 +76,7 @@ def run(self): try: self._read_output(self._session, self._channel, self._timeout, self._timeout_read_data, self.stdout, self.stderr) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.raised = exc def _read_output( # pylint: disable=too-many-arguments,too-many-branches @@ -150,7 +150,7 @@ def run(self): try: time_to_wait = self._session.eagain( self._session.keepalive_send, timeout=self._keepalive_timeout) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 time_to_wait = self._keepalive_timeout sleep(time_to_wait) @@ -356,7 +356,7 @@ def _auth(self): with self.session.lock: self.session.agent_auth(self.user) return - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass self._password_auth() @@ -386,7 +386,7 @@ def _password_auth(self): self.session.eagain( self.session.userauth_password, args=(self.user, self.password), timeout=self.timings.auth_timeout) - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 raise AuthenticationException("Password authentication failed") from error @staticmethod @@ -403,7 +403,7 @@ def _init_socket(self, host: str, port: int): if self.sock: try: self.sock.close() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass family = self._get_socket_family(host) if family is None: @@ -447,7 +447,7 @@ def _process_output( # pylint: disable=too-many-arguments, too-many-branches stdout_stream.write(data) for watcher in watchers: watcher.submit_line(data) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass if stderr_stream is not None: if reader.stderr.qsize(): @@ -457,7 +457,7 @@ def _process_output( # pylint: disable=too-many-arguments, too-many-branches stderr_stream.write(data) for watcher in watchers: watcher.submit_line(data) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass return True @@ -502,7 +502,7 @@ def connect(self, timeout: NullableTiming = __DEFAULT__): try: with self.flood_preventing.get_lock(self): self._connect() - except Exception as exc: + except Exception as exc: # noqa: BLE001 self.disconnect() raise ConnectError(str(exc)) from exc return @@ -517,7 +517,7 @@ def connect(self, timeout: NullableTiming = __DEFAULT__): except AuthenticationError: self.disconnect() raise # pylint: disable=broad-except - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.disconnect() if perf_counter() > end_time: ex_msg = f'Failed to connect in {timeout} seconds, last error: ({type(exc).__name__}){str(exc)}' @@ -540,14 +540,14 @@ def disconnect(self): if self.session is not None: try: self.session.eagain(self.session.disconnect) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass del self.session self.session = None if self.sock is not None: try: self.sock.close() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass self.sock = None @@ -587,12 +587,12 @@ def run( # pylint: disable=unused-argument,too-many-arguments,too-many-locals if self.session is None: self.connect() channel = self.open_channel() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 return self._complete_run( channel, FailedToRunCommand(result, exc), timeout_reached, timeout, result, warn, stdout, stderr) try: self._apply_env(channel, env) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 return self._complete_run( channel, FailedToRunCommand(result, exc), timeout_reached, timeout, result, warn, stdout, stderr) if watchers: @@ -602,7 +602,7 @@ def run( # pylint: disable=unused-argument,too-many-arguments,too-many-locals self.execute(command, channel=channel, use_pty=False) self._process_output(watchers, encoding, stdout, stderr, reader, timeout, self.timings.interactive_read_data_chunk_timeout) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 exception = FailedToReadCommandOutput(result, exc) if reader.is_alive(): reader.stop() @@ -615,7 +615,7 @@ def run( # pylint: disable=unused-argument,too-many-arguments,too-many-locals timeout_reached = not self._process_output_no_watchers( self.session, channel, encoding, stdout, stderr, timeout, self.timings.read_data_chunk_timeout) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 exception = FailedToReadCommandOutput(result, exc) return self._complete_run(channel, exception, timeout_reached, timeout, result, warn, stdout, stderr) @@ -637,11 +637,11 @@ def _complete_run(self, channel: Channel, exception: Exception, # pylint: disab try: with self.session.lock: channel.close() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 print(f'Failed to close channel due to the following error: {exc}') try: self.session.eagain(channel.wait_closed, timeout=self.timings.channel_close_timeout) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 print(f'Failed to close channel due to the following error: {exc}') exit_status = channel.get_exit_status() self.session.drop_channel(channel) @@ -679,7 +679,7 @@ def open_channel(self) -> Channel: chan = self.session.eagain(self.session.open_session) if chan != LIBSSH2_ERROR_EAGAIN: break - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass delay = next(delay_iter, delay) sleep(delay) diff --git a/sdcm/remote/libssh2_client/session.py b/sdcm/remote/libssh2_client/session.py index 20ddf01657f..b4ae1302b74 100644 --- a/sdcm/remote/libssh2_client/session.py +++ b/sdcm/remote/libssh2_client/session.py @@ -74,11 +74,11 @@ def drop_channel(self, channel: Channel): self.channels.remove(channel) try: channel.close() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass try: channel.wait_closed() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass del channel diff --git a/sdcm/remote/remote_base.py b/sdcm/remote/remote_base.py index 10cdea1e489..9e97e78ff62 100644 --- a/sdcm/remote/remote_base.py +++ b/sdcm/remote/remote_base.py @@ -606,7 +606,7 @@ def _run(): except self.exception_retryable as exc: if self._run_on_retryable_exception(exc, new_session): raise - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 if self._run_on_exception(exc, verbose, ignore_status): raise return None diff --git a/sdcm/remote/remote_cmd_runner.py b/sdcm/remote/remote_cmd_runner.py index 1e114b90127..2d099e66ccb 100644 --- a/sdcm/remote/remote_cmd_runner.py +++ b/sdcm/remote/remote_cmd_runner.py @@ -65,7 +65,7 @@ def _ssh_ping(self) -> bool: self.log.debug("%s: sleeping %s seconds before next retry", auth_exception, self.auth_sleep_time) self.ssh_up_thread_termination.wait(self.auth_sleep_time) return False - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self.log.debug(details) return False diff --git a/sdcm/remote/remote_libssh_cmd_runner.py b/sdcm/remote/remote_libssh_cmd_runner.py index 26fd97c4dfd..60ca8c107c6 100644 --- a/sdcm/remote/remote_libssh_cmd_runner.py +++ b/sdcm/remote/remote_libssh_cmd_runner.py @@ -54,11 +54,11 @@ def is_up(self, timeout: float = 30) -> bool: try: if self.connection.check_if_alive(timeout): return True - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 try: self.connection.close() self.connection.open(timeout) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass return False @@ -68,11 +68,11 @@ def _run_on_retryable_exception(self, exc: Exception, new_session: bool) -> bool self.log.debug('Reestablish the session...') try: self.connection.disconnect() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass try: self.connection.connect() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass if self._is_error_retryable(str(exc)) or isinstance(exc, self.exception_retryable): raise RetryableNetworkException(str(exc), original=exc) diff --git a/sdcm/results_analyze/__init__.py b/sdcm/results_analyze/__init__.py index 73d94a1a2ad..92407f371db 100644 --- a/sdcm/results_analyze/__init__.py +++ b/sdcm/results_analyze/__init__.py @@ -348,7 +348,7 @@ def sort_results_by_versions(results: list[Any]): key=lambda version: version, reverse=True)} return best_results - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Search best results per version failed. Error: %s", exc) return {} @@ -403,7 +403,7 @@ def _calculate_relative_change_magnitude(current_value, best_value): best['average_time_operation_in_sec_diff'] = _calculate_relative_change_magnitude( current_result[nemesis]['average_time_operation_in_sec'], best['average_time_operation_in_sec']) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Compare results failed: %s", exc) def check_regression(self, test_id, data, is_gce=False, node_benchmarks=None, email_subject_postfix=None): # pylint: disable=too-many-locals, too-many-branches, too-many-statements, too-many-arguments diff --git a/sdcm/results_analyze/test.py b/sdcm/results_analyze/test.py index 8c172ff2c91..a7dc8645d6b 100644 --- a/sdcm/results_analyze/test.py +++ b/sdcm/results_analyze/test.py @@ -495,7 +495,7 @@ def get_by_params(cls, es_index=es_index, **params): size=10000, filter_path=filter_path, ) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Unable to find ES data: %s", exc) es_data = None @@ -566,7 +566,7 @@ def get_prior_tests(self, filter_path=None) -> typing.List['TestResultClass']: filter_path=filter_path, ) es_result = es_result.get('hits', {}).get('hits', None) if es_result else None - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Unable to find ES data: %s", exc) es_result = None diff --git a/sdcm/scan_operation_thread.py b/sdcm/scan_operation_thread.py index 9abae41060b..a97adee104d 100644 --- a/sdcm/scan_operation_thread.py +++ b/sdcm/scan_operation_thread.py @@ -155,7 +155,7 @@ def run_scan_event(self, cmd: str, self.fetch_result_pages(result=result, read_pages=self.fullscan_stats.read_pages) if not scan_op_event.message: scan_op_event.message = f"{type(self).__name__} operation ended successfully" - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error(traceback.format_exc()) msg = repr(exc) self.current_operation_stat.exceptions.append(repr(exc)) @@ -244,7 +244,7 @@ def get_table_clustering_order(self) -> str: session.default_consistency_level = ConsistencyLevel.ONE return get_table_clustering_order(ks_cf=self.fullscan_params.ks_cf, ck_name=self.fullscan_params.ck_name, session=session) - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 self.log.error(traceback.format_exc()) self.log.error('Failed getting table %s clustering order through node %s : %s', self.fullscan_params.ks_cf, node.name, diff --git a/sdcm/sct_config.py b/sdcm/sct_config.py index 9c998a5cdd4..1ed4359b12a 100644 --- a/sdcm/sct_config.py +++ b/sdcm/sct_config.py @@ -95,7 +95,7 @@ def str_or_list_or_eval(value: Union[str, List[str]]) -> List[str]: if isinstance(value, str): try: return ast.literal_eval(value) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass return [str(value), ] @@ -104,7 +104,7 @@ def str_or_list_or_eval(value: Union[str, List[str]]) -> List[str]: for val in value: try: ret_values += [ast.literal_eval(val)] - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 ret_values += [str(val)] return ret_values @@ -115,7 +115,7 @@ def int_or_list(value): try: value = int(value) return value - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass if isinstance(value, str): @@ -123,11 +123,11 @@ def int_or_list(value): values = value.split() [int(v) for v in values] # pylint: disable=expression-not-assigned return value - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass try: return ast.literal_eval(value) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass raise ValueError("{} isn't int or list".format(value)) @@ -137,7 +137,7 @@ def dict_or_str(value): if isinstance(value, str): try: return ast.literal_eval(value) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass if isinstance(value, dict): return value @@ -1750,7 +1750,7 @@ def __init__(self): # noqa: PLR0912, PLR0915 ami = get_branched_ami(scylla_version=scylla_version, region_name=region, arch=aws_arch)[0] else: ami = get_scylla_ami_versions(version=scylla_version, region_name=region, arch=aws_arch)[0] - except Exception as ex: + except Exception as ex: # noqa: BLE001 raise ValueError(f"AMIs for scylla_version='{scylla_version}' not found in {region} " f"arch={aws_arch}") from ex self.log.debug("Found AMI %s(%s) for scylla_version='%s' in %s", @@ -1764,7 +1764,7 @@ def __init__(self): # noqa: PLR0912, PLR0915 else: # gce_image.name format examples: scylla-4-3-6 or scylla-enterprise-2021-1-2 gce_image = get_scylla_gce_images_versions(version=scylla_version)[0] - except Exception as ex: + except Exception as ex: # noqa: BLE001 raise ValueError(f"GCE image for scylla_version='{scylla_version}' was not found") from ex self.log.debug("Found GCE image %s for scylla_version='%s'", gce_image.name, scylla_version) @@ -1828,7 +1828,7 @@ def __init__(self): # noqa: PLR0912, PLR0915 else: ami = get_scylla_ami_versions(version=oracle_scylla_version, region_name=region, arch=aws_arch)[0] - except Exception as ex: + except Exception as ex: # noqa: BLE001 raise ValueError(f"AMIs for oracle_scylla_version='{scylla_version}' not found in {region} " f"arch={aws_arch}") from ex @@ -2012,7 +2012,7 @@ def _load_environment_variables(self): if opt['env'] in os.environ: try: environment_vars[opt['name']] = opt['type'](os.environ[opt['env']]) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 raise ValueError( "failed to parse {} from environment variable".format(opt['env'])) from ex nested_keys = [key for key in os.environ if key.startswith(opt['env'] + '.')] @@ -2065,7 +2065,7 @@ def _validate_value(self, opt): opt['is_k8s_multitenant_value'] = False try: opt['type'](self.get(opt['name'])) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 if not (self.get("cluster_backend").startswith("k8s") and self.get("k8s_tenants_num") > 1 and opt.get("k8s_multitenancy_supported") @@ -2077,7 +2077,7 @@ def _validate_value(self, opt): for list_element in self.get(opt['name']): try: opt['type'](list_element) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 raise ValueError("failed to validate {}".format(opt['name'])) from ex opt['is_k8s_multitenant_value'] = True diff --git a/sdcm/sct_events/base.py b/sdcm/sct_events/base.py index f5de3c3e8c3..6d2e1124194 100644 --- a/sdcm/sct_events/base.py +++ b/sdcm/sct_events/base.py @@ -323,7 +323,7 @@ def __del__(self): warning = f"[SCT internal warning] {self} has not been published or dumped, maybe you missed .publish()" try: LOGGER.warning(warning) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 print(f"Exception while printing {warning}. Full exception: {exc}") diff --git a/sdcm/sct_events/decorators.py b/sdcm/sct_events/decorators.py index 588a2a29e57..41e4bf42060 100644 --- a/sdcm/sct_events/decorators.py +++ b/sdcm/sct_events/decorators.py @@ -24,7 +24,7 @@ def raise_event_on_failure(func): def wrapper(*args, **kwargs): try: return func(*args, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 ThreadFailedEvent(message=str(exc), traceback=format_exc()).publish() return None diff --git a/sdcm/sct_events/file_logger.py b/sdcm/sct_events/file_logger.py index 9795ed1c919..69790ba8795 100644 --- a/sdcm/sct_events/file_logger.py +++ b/sdcm/sct_events/file_logger.py @@ -134,7 +134,7 @@ def get_events_by_category(self, limit: Optional[int] = None) -> Dict[str, List[ event.append(line) if event: events_bucket.append("\n".join(event)) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 error_msg = f"{self}: failed to read {log_file}: {exc}" LOGGER.error(error_msg) if not events_bucket: diff --git a/sdcm/sct_events/filters.py b/sdcm/sct_events/filters.py index 719580d9da6..777cc46e334 100644 --- a/sdcm/sct_events/filters.py +++ b/sdcm/sct_events/filters.py @@ -94,7 +94,7 @@ def __init__(self, def _regex(self): try: return self.regex and re.compile(self.regex, self.regex_flags) - except Exception as exc: + except Exception as exc: # noqa: BLE001 raise ValueError(f'Compilation of the regexp "{self.regex}" failed with error: {exc}') from None def cancel_filter(self) -> None: diff --git a/sdcm/sct_events/handlers/schema_disagreement.py b/sdcm/sct_events/handlers/schema_disagreement.py index 20defa1a0ab..96dec95ccfa 100644 --- a/sdcm/sct_events/handlers/schema_disagreement.py +++ b/sdcm/sct_events/handlers/schema_disagreement.py @@ -48,7 +48,7 @@ def handle(self, event: CassandraStressLogEvent, tester_obj: "sdcm.tester.Cluste try: link = upload_sstables_to_s3(node, keyspace='system_schema', test_id=tester_obj.test_id) event.add_sstable_link(link) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("failed to upload system_schema sstables for node %s: %s", node.name, exc) event.add_gossip_info(gossip_info) event.add_peers_info(peers_info) diff --git a/sdcm/sct_events/operator.py b/sdcm/sct_events/operator.py index b71b592d0ef..af231ec123e 100644 --- a/sdcm/sct_events/operator.py +++ b/sdcm/sct_events/operator.py @@ -54,7 +54,7 @@ def add_info(self: T_log_event, node, line: str, line_number: int) -> T_log_even self.source_timestamp = datetime.datetime( year=year, month=month, day=day, hour=int(hour), minute=int(minute), second=int(second), microsecond=int(milliseconds), tzinfo=datetime.timezone.utc).timestamp() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass self.event_timestamp = time.time() self.node = str(node) diff --git a/sdcm/sct_runner.py b/sdcm/sct_runner.py index dbdfc981ef1..0fbd98bdb7b 100644 --- a/sdcm/sct_runner.py +++ b/sdcm/sct_runner.py @@ -375,7 +375,7 @@ def create_image(self) -> None: try: LOGGER.info("Terminating SCT Image Builder instance `%s'...", builder_instance_id) self._terminate_image_builder_instance(instance=instance) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Was not able to terminate `%s': %s\nPlease terminate manually!!!", builder_instance_id, ex) else: @@ -1244,7 +1244,7 @@ def update_sct_runner_tags(backend: str = None, test_runner_ip: str = None, test runner_to_update = runner_to_update[0] runner_to_update.sct_runner_class.set_tags(runner_to_update, tags=tags) LOGGER.info("Tags on SCT runner updated with: %s", tags) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Could not set SCT runner tags to: %s due to exc:\n%s", tags, exc) @@ -1343,7 +1343,7 @@ def clean_sct_runners(test_status: str, sct_runner_info.terminate() runners_terminated += 1 end_message = f"Number of cleaned runners: {runners_terminated}" - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Exception raised during termination of %s: %s", sct_runner_info, exc) end_message = "No runners have been terminated" diff --git a/sdcm/scylla_bench_thread.py b/sdcm/scylla_bench_thread.py index 79b9c2cc7ef..7c240e52287 100644 --- a/sdcm/scylla_bench_thread.py +++ b/sdcm/scylla_bench_thread.py @@ -216,7 +216,7 @@ def _run_stress(self, loader, loader_idx, cpu_idx): # pylint: disable=too-many- log_file=log_file_name, retry=0, ) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.configure_event_on_failure(stress_event=scylla_bench_event, exc=exc) return loader, result diff --git a/sdcm/send_email.py b/sdcm/send_email.py index 5043681e779..49750f71c1b 100644 --- a/sdcm/send_email.py +++ b/sdcm/send_email.py @@ -699,7 +699,7 @@ def send_perf_email(reporter, test_results, logs, email_recipients, testrun_dir, template=email_content['template']) try: reporter.send_email(subject=subject, content=html, files=email_content['attachments']) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Failed to create email due to the following error:\n%s", traceback.format_exc()) build_reporter("TestAborted", email_recipients, testrun_dir).send_report({ "job_url": os.environ.get("BUILD_URL"), @@ -723,7 +723,7 @@ def read_email_data_from_file(filename): with open(filename, encoding="utf-8") as file: data = file.read().strip() email_data = json.loads(data or '{}') - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Error during read email data file %s: %s", filename, details) return email_data @@ -741,5 +741,5 @@ def save_email_data_to_file(email_data, filepath): if email_data: with open(filepath, "w", encoding="utf-8") as json_file: json.dump(email_data, json_file) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Error during collecting data for email %s", details) diff --git a/sdcm/sla/libs/sla_utils.py b/sdcm/sla/libs/sla_utils.py index ea34c7bdcf1..1b5d477ec5c 100644 --- a/sdcm/sla/libs/sla_utils.py +++ b/sdcm/sla/libs/sla_utils.py @@ -383,7 +383,7 @@ def clean_auth(entities_list_of_dict): if auth: try: auth.drop() - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Failed to drop '%s'. Error: %s", auth.name, error) @staticmethod diff --git a/sdcm/sla/sla_tests.py b/sdcm/sla/sla_tests.py index 909a8146b6a..58aba4bd3cb 100644 --- a/sdcm/sla/sla_tests.py +++ b/sdcm/sla/sla_tests.py @@ -36,7 +36,7 @@ def run_stress_and_validate_scheduler_runtime_during_load(self, tester, read_cmd possible_issue={'less resources': 'scylla-enterprise#2717'} ) return None - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 wp_event.add_error([str(details)]) wp_event.full_traceback = traceback.format_exc() wp_event.severity = Severity.ERROR @@ -66,7 +66,7 @@ def alter_sl_and_validate_scheduler_runtime(self, tester, service_level, new_sha db_cluster=tester.db_cluster, possible_issue={'less resources': "scylla-enterprise#949"}) return None - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 wp_event.add_error([str(details)]) wp_event.full_traceback = traceback.format_exc() wp_event.severity = Severity.ERROR @@ -82,7 +82,7 @@ def detach_service_level_and_run_load(sl_for_detach, role_with_sl_to_detach, sle role_with_sl_to_detach.detach_service_level() time.sleep(sleep) return None - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 wp_event.add_error([str(details)]) wp_event.full_traceback = traceback.format_exc() wp_event.severity = Severity.ERROR @@ -98,7 +98,7 @@ def drop_service_level_and_run_load(sl_for_drop, role_with_sl_to_drop, sleep=600 role_with_sl_to_drop.reset_service_level() time.sleep(sleep) return None - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 wp_event.add_error([str(details)]) wp_event.full_traceback = traceback.format_exc() wp_event.severity = Severity.ERROR @@ -158,7 +158,7 @@ def validate_role_service_level_attributes_against_db(): 'scylla-enterprise#2572 or scylla-enterprise#2717'} ) return None - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 wp_event.add_error([str(details)]) wp_event.full_traceback = traceback.format_exc() wp_event.severity = Severity.ERROR @@ -204,7 +204,7 @@ def verify_stress_threads(tester, stress_queue): for stress in stress_queue: try: tester.verify_stress_thread(cs_thread_pool=stress) - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Stress verifying failed. Error: %s", error) @staticmethod diff --git a/sdcm/stress/latte_thread.py b/sdcm/stress/latte_thread.py index 87398aa6847..18418373126 100644 --- a/sdcm/stress/latte_thread.py +++ b/sdcm/stress/latte_thread.py @@ -213,7 +213,7 @@ def _run_stress(self, loader, loader_idx, cpu_idx): ) return self.parse_final_output(result) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.configure_event_on_failure(stress_event=latte_stress_event, exc=exc) return {} diff --git a/sdcm/stress_thread.py b/sdcm/stress_thread.py index fb6c4f4c839..3d7869dbc52 100644 --- a/sdcm/stress_thread.py +++ b/sdcm/stress_thread.py @@ -214,7 +214,7 @@ def _get_available_suboptions(self, loader, option, _cache={}): # pylint: disab cmd=f'cassandra-stress help {option} | grep "^Usage:"', timeout=self.timeout, ignore_status=True).stdout - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 return [] findings = re.findall(r' *\[([\w-]+?)[=?]*] *', result) _cache[option] = findings @@ -348,7 +348,7 @@ def _run_cs_stress(self, loader, loader_idx, cpu_idx, keyspace_idx): # pylint: reporter = CassandraStressVersionReporter( cmd_runner, prefix, loader.parent_cluster.test_config.argus_client()) reporter.report() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 LOGGER.info("Failed to collect cassandra-stress version information", exc_info=True) with cleanup_context, \ CassandraStressExporter(instance_name=cmd_runner_name, @@ -370,7 +370,7 @@ def _run_cs_stress(self, loader, loader_idx, cpu_idx, keyspace_idx): # pylint: try: with SoftTimeoutContext(timeout=self.soft_timeout, operation="cassandra-stress"): result = cmd_runner.run(cmd=node_cmd, timeout=self.hard_timeout, log_file=log_file_name, retry=0) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.configure_event_on_failure(stress_event=cs_stress_event, exc=exc) return loader, result, cs_stress_event @@ -403,7 +403,7 @@ def get_results(self) -> list[dict | None]: node_cs_res = BaseLoaderSet._parse_cs_summary(lines) # pylint: disable=protected-access if node_cs_res: ret.append(node_cs_res) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 event.add_error([f"Failed to process stress summary due to {exc}"]) event.severity = Severity.CRITICAL event.event_error() diff --git a/sdcm/teardown_validators/sstables.py b/sdcm/teardown_validators/sstables.py index 62e006bddf0..3dd95b1f746 100644 --- a/sdcm/teardown_validators/sstables.py +++ b/sdcm/teardown_validators/sstables.py @@ -62,7 +62,7 @@ def validate(self): parallel_obj = ParallelObject(objects=self.cluster.nodes, timeout=timeout) parallel_obj.run(run_scrub, ignore_exceptions=False, unpack_objects=True) LOGGER.info("Nodetool scrub validation finished") - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Error during nodetool scrub validation: %s", exc) ValidatorEvent( message=f'Error during nodetool scrub validation: {exc}', severity=Severity.ERROR).publish() diff --git a/sdcm/tester.py b/sdcm/tester.py index 22549d6a2b3..be74e33d101 100644 --- a/sdcm/tester.py +++ b/sdcm/tester.py @@ -234,7 +234,7 @@ def decor(*args, **kwargs): self.log.debug("Silently running '%s'", name) result = funct(*args, **kwargs) self.log.debug("Finished '%s'. No errors were silenced.", name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.debug("Finished '%s'. %s exception was silenced.", name, str(type(exc))) self._store_test_result(args[0], exc, exc.__traceback__, name) return result @@ -270,7 +270,7 @@ def critical_failure_handler(signum, frame): # pylint: disable=unused-argument if TestConfig().tester_obj().teardown_started: TEST_LOG.info("A critical event happened during tearDown") return - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass raise CriticalTestFailure("Critical Error has failed the test") # pylint: disable=raise-missing-from @@ -440,7 +440,7 @@ def send_argus_heartbeat(client: ArgusSCTClient, stop_signal: threading.Event): break try: client.sct_heartbeat() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 self.log.warning("Failed to submit heartbeat to argus, Try #%s", fail_count + 1) fail_count += 1 time.sleep(30.0) @@ -611,7 +611,7 @@ def argus_collect_gemini_results(self): "oracle_node_scylla_version": self.cs_db_cluster.nodes[0].scylla_version if self.cs_db_cluster else "N/A", "oracle_nodes_count": self.params.get("n_test_oracle_db_nodes"), }) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 self.log.warning("Error submitting gemini results to argus", exc_info=True) def _init_data_validation(self): @@ -2400,7 +2400,7 @@ def truncate_cf(self, ks_name: str, table_name: str, session: Session, truncate_ try: timeout = f" USING TIMEOUT {truncate_timeout_sec}s" if truncate_timeout_sec else "" session.execute('TRUNCATE TABLE {0}.{1}{2}'.format(ks_name, table_name, timeout)) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 self.log.debug('Failed to truncate base table {0}.{1}. Error: {2}'.format(ks_name, table_name, str(ex))) def create_materialized_view(self, ks_name, base_table_name, mv_name, mv_partition_key, mv_clustering_key, session, # noqa: PLR0913 @@ -2514,7 +2514,7 @@ def copy_table(self, node, src_keyspace, src_table, dest_keyspace, # pylint: di try: result = self.copy_data_between_tables(node, src_keyspace, src_table, dest_keyspace, dest_table, columns_list) - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 self.log.error('Copying data from %s to %s failed with error: %s', src_table, dest_table, error) return False @@ -2540,7 +2540,7 @@ def copy_view(self, node, src_keyspace, src_view, dest_keyspace, # pylint: disa try: result = self.copy_data_between_tables(node, src_keyspace, src_view, dest_keyspace, dest_table, columns_list) - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 self.log.error('Copying data from %s to %s failed with error %s', src_view, dest_table, error) return False @@ -2656,7 +2656,7 @@ def copy_data_between_tables(self, node, src_keyspace, src_table, dest_keyspace, 'Actually inserted rows: %s.', len(source_table_rows), succeeded_rows) return False - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.warning('Problem during copying data: %s', exc) return False @@ -3114,7 +3114,7 @@ def get_data_set_size(self, cs_cmd): # pylint: disable=inconsistent-return-stat """ try: return int(re.search(r"n=(\d+) ", cs_cmd).group(1)) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 self.fail("Unable to get data set size from cassandra-stress command: %s" % cs_cmd) return None @@ -3127,7 +3127,7 @@ def get_c_s_column_definition(self, cs_cmd): # pylint: disable=inconsistent-ret if search_res := re.search(r".* -col ('.*') .*", cs_cmd): return search_res.group(1) return None - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 self.fail("Unable to get column definition from cassandra-stress command: %s" % cs_cmd) return None @@ -3509,7 +3509,7 @@ def save_email_data(self): email_data = self.get_email_data() self._argus_add_relocatable_pkg(email_data) self.argus_collect_screenshots(email_data) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Error while saving email data. Error: %s\nTraceback: %s", exc, traceback.format_exc()) json_file_path = os.path.join(self.logdir, "email_data.json") diff --git a/sdcm/tombstone_gc_verification_thread.py b/sdcm/tombstone_gc_verification_thread.py index df42cde5a3c..1aa1191170b 100644 --- a/sdcm/tombstone_gc_verification_thread.py +++ b/sdcm/tombstone_gc_verification_thread.py @@ -74,7 +74,7 @@ def _run_tombstone_gc_verification(self): try: self.tombstone_gc_verification() tombstone_event.message = "Tombstone GC verification ended successfully" - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 msg = str(exc) msg = f"{msg} while running Nemesis: {db_node.running_nemesis}" if db_node.running_nemesis else msg tombstone_event.message = msg diff --git a/sdcm/utils/adaptive_timeouts/__init__.py b/sdcm/utils/adaptive_timeouts/__init__.py index 00e6557f037..6ad18e71f2f 100644 --- a/sdcm/utils/adaptive_timeouts/__init__.py +++ b/sdcm/utils/adaptive_timeouts/__init__.py @@ -18,7 +18,7 @@ def _get_decommission_timeout(node_info_service: NodeLoadInfoService) -> tuple[i timeout = int(node_info_service.node_data_size_mb * 0.03) timeout = max(timeout, 7200) # 2 hours minimum return timeout, node_info_service.as_dict() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Failed to calculate decommission timeout: \n%s \nDefaulting to 6 hours", exc) return 6*60*60, {} @@ -27,7 +27,7 @@ def _get_soft_timeout(node_info_service: NodeLoadInfoService, timeout: int | flo # no timeout calculation - just return the timeout passed as argument along with node load info try: return timeout, node_info_service.as_dict() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Failed to get node info for timeout: \n%s", exc) return timeout, {} @@ -114,5 +114,5 @@ def adaptive_timeout(operation: Operations, node: "BaseNode", stats_storage: Ada if load_metrics: stats_storage.store(metrics=load_metrics, operation=operation.name, duration=duration, timeout=timeout, timeout_occurred=timeout_occurred) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Failed to store adaptive timeout stats: \n%s", exc) diff --git a/sdcm/utils/adaptive_timeouts/load_info_store.py b/sdcm/utils/adaptive_timeouts/load_info_store.py index d134fb049cc..2d11575a096 100644 --- a/sdcm/utils/adaptive_timeouts/load_info_store.py +++ b/sdcm/utils/adaptive_timeouts/load_info_store.py @@ -81,7 +81,7 @@ def _get_node_load(self) -> tuple[float, float, float]: load_5 = float(metrics['node_load5']) load_15 = float(metrics['node_load15']) return load_1, load_5, load_15 - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Couldn't get node load from prometheus metrics. Error: %s", exc) # fallback to uptime load_1, load_5, load_15 = self.remoter.run('uptime').stdout.split("load average: ")[1].split(",") diff --git a/sdcm/utils/aws_utils.py b/sdcm/utils/aws_utils.py index 87c879c43b1..5ca9f8fe3f5 100644 --- a/sdcm/utils/aws_utils.py +++ b/sdcm/utils/aws_utils.py @@ -123,7 +123,7 @@ def delete_network_interfaces_of_sg(self, sg_id: str): if attachment_id := attachment.get('AttachmentId'): try: self.ec2_client.detach_network_interface(AttachmentId=attachment_id, Force=True) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Failed to detach network interface (%s) attachment %s:\n%s", network_interface_id, attachment_id, exc) @@ -133,7 +133,7 @@ def delete_network_interfaces_of_sg(self, sg_id: str): network_interface_id = interface_description['NetworkInterfaceId'] try: self.ec2_client.delete_network_interface(NetworkInterfaceId=network_interface_id) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Failed to delete network interface %s :\n%s", network_interface_id, exc) def destroy_attached_security_groups(self): @@ -141,7 +141,7 @@ def destroy_attached_security_groups(self): # even when cluster is gone try: sg_list = self.attached_security_group_ids - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Failed to get list of security groups:\n%s", exc) return @@ -151,12 +151,12 @@ def destroy_attached_security_groups(self): # In this case you need to forcefully detach interfaces and delete them to make nodegroup deletion possible. try: self.delete_network_interfaces_of_sg(security_group_id) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("destroy_attached_security_groups: %s", exc) try: self.ec2_client.delete_security_group(GroupId=security_group_id) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Failed to delete security groups %s, due to the following error:\n%s", security_group_id, exc) @@ -166,7 +166,7 @@ def _destroy_attached_nodegroups(): for node_group_name in self._get_attached_nodegroup_names(status=status): try: self.eks_client.delete_nodegroup(clusterName=self.short_cluster_name, nodegroupName=node_group_name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Failed to delete nodegroup %s/%s, due to the following error:\n%s", self.short_cluster_name, node_group_name, exc) time.sleep(10) @@ -181,7 +181,7 @@ def _destroy_attached_nodegroups(): def destroy_cluster(self): try: self.eks_client.delete_cluster(name=self.short_cluster_name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Failed to delete cluster %s, due to the following error:\n%s", self.short_cluster_name, exc) @@ -205,7 +205,7 @@ def destroy_oidc_provider(self): LOGGER.warning( "Couldn't find any OIDC provider associated with the '%s' EKS cluster", self.short_cluster_name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning( "Failed to delete OIDC provider for the '%s' cluster due to " "the following error:\n%s", diff --git a/sdcm/utils/benchmarks.py b/sdcm/utils/benchmarks.py index 3a531772235..193b761db5a 100644 --- a/sdcm/utils/benchmarks.py +++ b/sdcm/utils/benchmarks.py @@ -202,7 +202,7 @@ def _compare_results(self): margins=Margins(sysbench_eps=0.03, cassandra_fio_read_bw=0.01, cassandra_fio_write_bw=0.01))) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning( "Failed to generate comparable result for the following item:\n%s" "\nException:%s", runner.benchmark_results, exc) @@ -236,7 +236,7 @@ def _get_average_results(es_docs: list): cassandra_fio_read_bw=item["cassandra_fio_lcs_64k_read"]["read"]["bw"], cassandra_fio_write_bw=item["cassandra_fio_lcs_64k_write"]["write"]["bw"] )) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning( "Failed to generate comparable result for the following item:\n%s" "\nException:%s", item, exc) @@ -296,7 +296,7 @@ def _install_ubuntu_prerequisites(self): for pkg in package_list: self._node.install_package(pkg) LOGGER.info("Ubuntu prerequisites for the node benchmarks installed.") - except Exception as exc: + except Exception as exc: # noqa: BLE001 LOGGER.warning("Failed to install Ubuntu prerequisites for the node benchmarking tools. " "Exception:\n%s", exc) @@ -342,7 +342,7 @@ def _get_fio_results(self): for job in cassandra_fio_jobs: jsoned_output.update({f'cassandra_fio_{job["jobname"]}': job}) self.benchmark_results.update(jsoned_output) - except Exception as exc: + except Exception as exc: # noqa: BLE001 LOGGER.warning("Failed to get cassandra-fio result for node %s with exception:\n%s", self.node_name, exc) def run_benchmarks(self): diff --git a/sdcm/utils/bisect_test.py b/sdcm/utils/bisect_test.py index bdf94a384e3..dec2c40d0ac 100644 --- a/sdcm/utils/bisect_test.py +++ b/sdcm/utils/bisect_test.py @@ -111,7 +111,7 @@ def update_binaries(node): raise ValueError('failed to get version from node: ', node.name) logger.info('successfully updated binaries to version: %s', version) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 logger.warning('error during upgrade: %s \n verifying next closest version.', exc) del repo_urls[mid] high -= 1 diff --git a/sdcm/utils/cloud_monitor/resources/__init__.py b/sdcm/utils/cloud_monitor/resources/__init__.py index 5e46b1e76c7..ed444753d96 100644 --- a/sdcm/utils/cloud_monitor/resources/__init__.py +++ b/sdcm/utils/cloud_monitor/resources/__init__.py @@ -23,7 +23,7 @@ def __init__(self, cloud, name, instance_id, region_az, state, lifecycle, instan try: self.price = self.pricing.get_instance_price(region=self.region, instance_type=self.instance_type, state=self.state, lifecycle=self.lifecycle) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 self.price = -0.0 # to indicate in the report that we were unable to get the price. @property diff --git a/sdcm/utils/cloud_monitor/resources/instances.py b/sdcm/utils/cloud_monitor/resources/instances.py index 82348b5e29a..269b96e3aca 100644 --- a/sdcm/utils/cloud_monitor/resources/instances.py +++ b/sdcm/utils/cloud_monitor/resources/instances.py @@ -47,7 +47,7 @@ def get_owner_from_cloud_trail(self): for event in result["Events"]: if event['EventName'] == 'RunInstances': return event["Username"] - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Error occurred when trying to find an owner for '%s' in CloudTrail: %s", self._instance['InstanceId'], exc) return None diff --git a/sdcm/utils/common.py b/sdcm/utils/common.py index 5e058952e64..b0c199ca4f5 100644 --- a/sdcm/utils/common.py +++ b/sdcm/utils/common.py @@ -118,7 +118,7 @@ def _remote_get_hash(remoter, file_path): try: result = remoter.run('md5sum {}'.format(file_path), verbose=True) return result.stdout.strip().split()[0] - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error(str(details)) return None @@ -285,7 +285,7 @@ def upload_file(self, file_path, dest_dir=''): LOGGER.info("Set public read access") self.set_public_access(key=s3_obj) return s3_url - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Unable to upload to S3: %s", details) return "" @@ -314,7 +314,7 @@ def download_file(self, link, dst_dir): LOGGER.info("Downloaded finished") return os.path.join(os.path.abspath(dst_dir), file_name) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("File {} is not downloaded by reason: {}".format(key_name, details)) return "" @@ -482,7 +482,7 @@ def inner(*args, **kwargs): except FuturesTimeoutError as exception: results.append(ParallelObjectResult(obj=target_obj, exc=exception, result=None)) time_out = 0.001 # if there was a timeout on one of the futures there is no need to wait for all - except Exception as exception: # pylint: disable=broad-except + except Exception as exception: # pylint: disable=broad-except # noqa: BLE001 results.append(ParallelObjectResult(obj=target_obj, exc=exception, result=None)) else: results.append(ParallelObjectResult(obj=target_obj, exc=None, result=result)) @@ -780,13 +780,13 @@ def delete_image(image): for container in containers: try: delete_container(container) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Failed to delete container %s on host `%s'", container, container.client.info()["Name"]) for image in images: try: delete_image(image) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Failed to delete image tag(s) %s on host `%s'", image.tags, image.client.info()["Name"]) @@ -1040,7 +1040,7 @@ def clean_test_security_groups(tags_dict, regions=None, dry_run=False): try: response = client.delete_security_group(GroupId=group_id) LOGGER.debug("Done. Result: %s\n", response) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Failed with: %s", str(ex)) @@ -1123,7 +1123,7 @@ def clean_load_balancers_aws(tags_dict, regions=None, dry_run=False): try: response = client.delete_load_balancer(LoadBalancerName=arn.split('/')[1]) LOGGER.debug("Done. Result: %s\n", response) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Failed with: %s", str(ex)) @@ -1200,7 +1200,7 @@ def clean_cloudformation_stacks_aws(tags_dict, regions=None, dry_run=False): try: response = client.delete_stack(StackName=arn.split('/')[1]) LOGGER.debug("Done. Result: %s\n", response) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug("Failed with: %s", str(ex)) @@ -1274,7 +1274,7 @@ def clean_launch_templates_aws(tags_dict, regions=None, dry_run=False): LOGGER.info( "Successfully deleted '%s' LaunchTemplate. Response: %s\n", (current_lt_name or current_lt_id), response) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 LOGGER.info("Failed to delete the '%s' LaunchTemplate: %s", deletion_args, str(ex)) @@ -1404,7 +1404,7 @@ def __init__(self): def list_gke_clusters(self) -> list: try: output = self.gcloud.run("container clusters list --format json") - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("`gcloud container clusters list --format json' failed to run: %s", exc) else: try: @@ -1420,7 +1420,7 @@ def list_orphaned_gke_disks(self) -> dict: try: disks = json.loads(self.gcloud.run( 'compute disks list --format="json(name,zone)" --filter="name~^gke-.*-pvc-.* AND -users:*"')) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("`gcloud compute disks list' failed to run: %s", exc) else: for disk in disks: @@ -1479,13 +1479,13 @@ def list_clusters(self) -> list: # pylint: disable=no-self-use for aws_region in regions or all_aws_regions(): try: cluster_names = boto3.client('eks', region_name=aws_region).list_clusters()['clusters'] - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Failed to get list of EKS clusters in the '%s' region: %s", aws_region, exc) return [] for cluster_name in cluster_names: try: eks_clusters.append(EksCluster(cluster_name, aws_region)) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Failed to get body of cluster on EKS: %s", exc) return eks_clusters @@ -1602,7 +1602,7 @@ def delete_cluster(cluster): try: res = cluster.destroy() LOGGER.info("%s deleted=%s", cluster.name, res) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error(exc) ParallelObject(gke_clusters_to_clean, timeout=180).run(delete_cluster, ignore_exceptions=True) @@ -1621,7 +1621,7 @@ def clean_orphaned_gke_disks(tags_dict: dict, dry_run: bool = False) -> None: gke_cleaner.clean_disks(disk_names=disk_names, zone=zone) LOGGER.info("Deleted following orphaned GKE disks in the '%s' zone (%s project): %s", zone, os.environ.get("SCT_GCE_PROJECT"), disk_names) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error(exc) @@ -1643,7 +1643,7 @@ def delete_cluster(cluster): res = cluster.destroy() LOGGER.info("'%s' EKS cluster in the '%s' region has been deleted. Response=%s", cluster.name, cluster.region_name, res) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error(exc) ParallelObject(eks_clusters_to_clean, timeout=180).run(delete_cluster, ignore_exceptions=True) @@ -1755,7 +1755,7 @@ def safe_kill(pid, signal): try: os.kill(pid, signal) return True - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 return False @@ -2136,7 +2136,7 @@ def remove_files(path): shutil.rmtree(path=path, ignore_errors=True) if os.path.isfile(path): os.remove(path) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Error during remove archived logs %s", details) LOGGER.info("Remove temporary data manually: \"%s\"", path) @@ -2154,7 +2154,7 @@ def create_remote_storage_dir(node, path='') -> Optional[str, None]: 'Remote storing folder not created.\n %s', result) remote_dir = node_remote_dir - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Error during creating remote directory %s", details) return None @@ -2199,7 +2199,7 @@ def update_certificates(db_csr='data_dir/ssl_conf/example/db.csr', cadb_pem='dat f'-out {db_crt} -days 365') localrunner.run(f'openssl x509 -enddate -noout -in {db_crt}') new_crt = localrunner.run(f'cat {db_crt}').stdout - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 raise Exception('Failed to update certificates by openssl: %s' % ex) from None return new_crt @@ -2750,7 +2750,7 @@ def approach_enospc(): LOGGER.debug('Cost 90% free space on /var/lib/scylla/ by {}'.format(occupy_space_cmd)) try: target_node.remoter.sudo(occupy_space_cmd, verbose=True) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning(str(details)) return bool(list(no_space_log_reader)) @@ -2951,7 +2951,7 @@ def walk_thru_data(data, path: str, separator: str = '/') -> Any: if name.isalnum() and isinstance(current_value, (list, tuple, set)): try: current_value = current_value[int(name)] - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 current_value = None continue current_value = current_value.get(name, None) diff --git a/sdcm/utils/data_validator.py b/sdcm/utils/data_validator.py index 91fc13f130b..2936d0b2723 100644 --- a/sdcm/utils/data_validator.py +++ b/sdcm/utils/data_validator.py @@ -619,7 +619,7 @@ def analyze_updated_data_and_save_in_file(self, data_for_validation: DataForVali try: row_data.update({key: list(session.execute(query % (select_columns, table)))}) - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Query %s failed. Error: %s", query % table, error) row_data.update({'source_all_columns': list(session.execute(query % (columns_for_validation, diff --git a/sdcm/utils/database_query_utils.py b/sdcm/utils/database_query_utils.py index 12f747c674f..59115416253 100644 --- a/sdcm/utils/database_query_utils.py +++ b/sdcm/utils/database_query_utils.py @@ -93,7 +93,7 @@ def collect_partitions_info(self, ignore_limit_rows_number: bool = False) -> dic session.default_consistency_level = ConsistencyLevel.QUORUM pk_list = sorted(get_partition_keys(ks_cf=self.table_name, session=session, pk_name=self.primary_key_column)) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 TestFrameworkEvent(source=self.__class__.__name__, message=error_message.format(exc), severity=Severity.ERROR).publish() return None @@ -120,7 +120,7 @@ def collect_partitions_info(self, ignore_limit_rows_number: bool = False) -> dic statement=count_pk_rows_cmd, retries=1, timeout=600, raise_on_exceeded=True, verbose=False) pk_rows_num_result = pk_rows_num_query_result[0].count - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 TestFrameworkEvent(source=self.__class__.__name__, message=error_message.format(exc), severity=Severity.ERROR).publish() return None diff --git a/sdcm/utils/docker_utils.py b/sdcm/utils/docker_utils.py index 1c9604067c7..6bdd098f546 100644 --- a/sdcm/utils/docker_utils.py +++ b/sdcm/utils/docker_utils.py @@ -249,7 +249,7 @@ def destroy_container(cls, instance: INodeWithContainerManager, name: str, ignor try: with open(logfile, "ab") as log: log.write(container.logs()) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Unable to write container logs to %s", logfile, exc_info=exc) else: LOGGER.debug("Container %s logs written to %s", container, logfile) @@ -266,7 +266,7 @@ def destroy_all_containers(cls, instance: INodeWithContainerManager, ignore_keep for name in tuple(instance._containers.keys()): try: cls.destroy_container(instance, name, ignore_keepalive=ignore_keepalive) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("%s: some exception raised during container `%s' destroying", instance, name, exc_info=exc) @classmethod diff --git a/sdcm/utils/gce_utils.py b/sdcm/utils/gce_utils.py index 28ec20e4a33..7fe5ef91d58 100644 --- a/sdcm/utils/gce_utils.py +++ b/sdcm/utils/gce_utils.py @@ -144,10 +144,10 @@ def _span_container(self): return try: self._container = self._instance._get_gcloud_container() # pylint: disable=protected-access - except Exception as exc: + except Exception as exc: # noqa: BLE001 try: ContainerManager.destroy_container(self._instance, self._name) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass raise exc from None @@ -157,7 +157,7 @@ def _destroy_container(self): return try: ContainerManager.destroy_container(self._instance, self._name) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass self._container = None diff --git a/sdcm/utils/git.py b/sdcm/utils/git.py index 82b24baa3ee..b22ccf78578 100644 --- a/sdcm/utils/git.py +++ b/sdcm/utils/git.py @@ -103,5 +103,5 @@ def clone_repo(remoter, repo_url: str, destination_dir_name: str = "", clone_as_ remoter.run(clone_cmd) LOGGER.debug("Finished cloning from %s.", repo_url) - except Exception as exc: + except Exception as exc: # noqa: BLE001 LOGGER.warning("Failed to clone from %s. Failed with: %s", repo_url, exc) diff --git a/sdcm/utils/issues.py b/sdcm/utils/issues.py index 4ea40e75b6e..d7301aa20f7 100644 --- a/sdcm/utils/issues.py +++ b/sdcm/utils/issues.py @@ -96,7 +96,7 @@ def get_issue_details(self, issue): # this would mean that we would assume issue is open, and enable the skips needed, without having the # actual data of the issue return github.Issue.Issue(requester=None, headers={}, attributes=dict(state='open'), completed=True) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 logging.warning("failed to get issue: %s", issue) TestFrameworkEvent(source=self.__class__.__name__, message=f"failed to get issue {issue}", diff --git a/sdcm/utils/k8s/__init__.py b/sdcm/utils/k8s/__init__.py index 5f99661bfa8..a494ef2d0ca 100644 --- a/sdcm/utils/k8s/__init__.py +++ b/sdcm/utils/k8s/__init__.py @@ -180,7 +180,7 @@ def check_if_api_not_operational(self, kluster, num_requests=20): try: self._api_test(kluster) passed += 1 - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 time.sleep(1 / self.rate_limit) return passed < num_requests * 0.8 @@ -553,7 +553,7 @@ def gather_k8s_logs_by_operator(cls, kluster, logdir_path=None): # Error: destination directory "%logdir_path%/must-gather" is not empty LOCALRUNNER.run(f"mkdir -p {logdir_path}/must-gather && rm -rf {logdir_path}/must-gather/*") LOCALRUNNER.run(gather_logs_cmd) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning( "Failed to run scylla-operator's 'must gather' command: %s", exc, extra={'prefix': kluster.region_name}) @@ -563,7 +563,7 @@ def gather_k8s_logs_by_operator(cls, kluster, logdir_path=None): extra={'prefix': kluster.region_name}) try: LOCALRUNNER.run(f"rm {operator_bin_path}") - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning( "Failed to delete the the scylla-operator binary located at '%s': %s", operator_bin_path, exc, extra={'prefix': kluster.region_name}) @@ -784,7 +784,7 @@ def run(self): self._check_token_validity_in_temporary_location() self._replace_active_token_by_token_from_temporary_location() LOGGER.debug('Cloud token has been updated and stored at %s', self._kubectl_token_path) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug('Failed to update cloud token: %s', exc) wait_time = 5 else: @@ -800,7 +800,7 @@ def _clean_up_token_in_temporary_location(self): try: if os.path.exists(self._temporary_token_path): os.unlink(self._temporary_token_path) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug('Failed to cleanup temporary token: %s', exc) def _check_token_validity_in_temporary_location(self): @@ -909,7 +909,7 @@ def run(self) -> None: try: for line in self._read_stream(): self._process_line(line) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 if not self._termination_event.wait(0.01): raise self.log.info("Scylla pods IP change tracker thread has been stopped") @@ -983,7 +983,7 @@ def _process_line(self, line: str) -> None: # pylint: disable=too-many-branches break else: break - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.warning( "Failed to parse following line: %s\nerr: %s", line, exc) @@ -1001,7 +1001,7 @@ def process_callback(callback, namespace, pod_name=None, add_pod_name_as_kwarg=F self.log.debug("Calling '%s' callback %s", func.__name__, suffix) try: func(*args, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.warning("Callback call failed %s: %s", suffix, str(exc)) data = self.mapper_dict.get(namespace, {}) @@ -1258,7 +1258,7 @@ def delete(self, path): last = int(last[1:-1]) try: del parent[last] - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass def as_dict(self): diff --git a/sdcm/utils/log_time_consistency.py b/sdcm/utils/log_time_consistency.py index 239576bbe3e..69bbacfce4d 100644 --- a/sdcm/utils/log_time_consistency.py +++ b/sdcm/utils/log_time_consistency.py @@ -96,7 +96,7 @@ def _analyze_file(cls, log_file: Path) -> tuple[dict[str, list[str]], dict[str, continue try: current_time = datetime.datetime.fromisoformat(line.split()[0]).timestamp() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 continue current_time_shift = prior_time - current_time if bucket_name := cls._get_timeshift_bucket_name(current_time_shift): @@ -132,7 +132,7 @@ def _analyze_file(cls, log_file: Path) -> tuple[dict[str, list[str]], dict[str, sct_time, event_time = match.groups() sct_time = datetime.datetime.fromisoformat(sct_time).timestamp() event_time = datetime.datetime.fromisoformat(event_time).timestamp() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 continue current_time_shift = sct_time - event_time if bucket_name := cls._get_timeshift_bucket_name(time_shift=current_time_shift): diff --git a/sdcm/utils/nemesis_utils/indexes.py b/sdcm/utils/nemesis_utils/indexes.py index 4f9933828d7..4e203123d19 100644 --- a/sdcm/utils/nemesis_utils/indexes.py +++ b/sdcm/utils/nemesis_utils/indexes.py @@ -36,7 +36,7 @@ def is_cf_a_view(node: BaseNode, ks, cf) -> bool: f" WHERE keyspace_name = '{ks}'" f" AND view_name = '{cf}'") return result and bool(len(result.one())) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.debug('Got no result from system_schema.views for %s.%s table. Error: %s', ks, cf, exc) return False @@ -103,7 +103,7 @@ def verify_query_by_index_works(session, ks, cf, column) -> None: query = SimpleStatement(f'SELECT * FROM {ks}.{cf} WHERE "{column}" = %s LIMIT 100', fetch_size=100) LOGGER.debug("Verifying query by index works: %s", query) result = session.execute(query, parameters=(value,)) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 InfoEvent(message=f"Index {ks}.{cf}({column}) does not work in query: {query}. Reason: {exc}", severity=Severity.ERROR).publish() if len(list(result)) == 0: diff --git a/sdcm/utils/operations_thread.py b/sdcm/utils/operations_thread.py index 62b17223e74..25c8dd03538 100644 --- a/sdcm/utils/operations_thread.py +++ b/sdcm/utils/operations_thread.py @@ -149,7 +149,7 @@ def _run_next_operation(self): self.log.debug("Thread operations queue depleted.") - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self.log.error(traceback.format_exc()) self.log.error("Encountered exception while performing a operation:\n%s", exc) diff --git a/sdcm/utils/quota.py b/sdcm/utils/quota.py index 7e11f310725..7cbf6fdb49a 100644 --- a/sdcm/utils/quota.py +++ b/sdcm/utils/quota.py @@ -104,7 +104,7 @@ def approach_end_of_quota(): try: LOGGER.debug('Cost 90% free space on /var/lib/scylla/ by {}'.format(occupy_space_cmd)) node.remoter.sudo(occupy_space_cmd, Verbose=True) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("We should have reached the expected I/O error and quota has exceeded\n" "Message: {}".format(str(exc))) return bool(list(quota_exceeded_appearances)) diff --git a/sdcm/utils/raft/__init__.py b/sdcm/utils/raft/__init__.py index 081a024acb9..6c564c98743 100644 --- a/sdcm/utils/raft/__init__.py +++ b/sdcm/utils/raft/__init__.py @@ -154,7 +154,7 @@ def get_group0_members(self) -> list[dict[str, str]]: for row in rows: group0_members.append({"host_id": str(row.server_id), "voter": row.can_vote}) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 err_msg = f"Get group0 members failed with error: {exc}" LOGGER.error(err_msg) diff --git a/sdcm/utils/raft/common.py b/sdcm/utils/raft/common.py index 102245b582b..3af7529ce0c 100644 --- a/sdcm/utils/raft/common.py +++ b/sdcm/utils/raft/common.py @@ -66,7 +66,7 @@ def _start_bootstrap(self): self.bootstrap_node.parent_cluster.node_setup(self.bootstrap_node, verbose=True) self.bootstrap_node.parent_cluster.node_startup(self.bootstrap_node, verbose=True) LOGGER.debug("Node %s was bootstrapped", self.bootstrap_node.name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Setup failed for node %s with err %s", self.bootstrap_node.name, exc) finally: self._set_wait_stop_event() @@ -82,7 +82,7 @@ def _abort_bootstrap(self, abort_action: Callable, log_message: str, timeout: in stop_event=self.bootstrap_node.stop_wait_db_up_event) abort_action() LOGGER.info("Scylla was stopped successfully on node %s", self.bootstrap_node.name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Abort was failed on node %s with error %s", self.bootstrap_node.name, exc) finally: self._set_wait_stop_event() @@ -149,7 +149,7 @@ def clean_and_restart_bootstrap_after_abort(self): self.bootstrap_node.start_scylla_jmx() self.db_cluster.check_nodes_up_and_normal( nodes=[self.bootstrap_node], verification_node=self.verification_node) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("Scylla service restart failed: %s", exc) self.clean_unbootstrapped_node() raise BootstrapStreamErrorFailure(f"Rebootstrap failed with error: {exc}") from exc diff --git a/sdcm/utils/remote_logger.py b/sdcm/utils/remote_logger.py index 96dee805421..4eb5d1fac97 100644 --- a/sdcm/utils/remote_logger.py +++ b/sdcm/utils/remote_logger.py @@ -107,7 +107,7 @@ def _retrieve(self, since: str) -> None: ignore_status=True, log_file=self._target_log_file, ) - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self._log.error("Error retrieving remote node DB service log: %s", details) @cached_property @@ -198,7 +198,7 @@ def _is_ready_to_retrieve(self) -> bool: def _is_file_exist(self, file_path: str) -> bool: try: return self._remoter.run(cmd=f"sudo test -e {file_path}", ignore_status=True).ok - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self._log.error("Error checking if file %s exists: %s", file_path, details) return False @@ -245,7 +245,7 @@ def _thread_body(self): if started: # Update last time only if command successfully started self._last_time_completed = time.time() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass def start(self): @@ -460,7 +460,7 @@ def _log_loop(self): self._log.debug( "'_read_log_line()': failed to read from pod %s log stream:%s", self._pod_name, exc) self._open_stream() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 self._log.error( "'_read_log_line()': failed to read from pod %s log stream:%s", self._pod_name, exc) self._open_stream() @@ -562,7 +562,7 @@ def _logger_cmd(self) -> str: else: wrong_scheduled_pods_on_scylla_node.append( f"{pod.metadata.name} ({pod.spec.node_name} node)") - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 self._log.warning("Failed to get pods list: %s", str(details)) if not wrong_scheduled_pods_on_scylla_node: diff --git a/sdcm/utils/sstable/s3_uploader.py b/sdcm/utils/sstable/s3_uploader.py index 7171a022e7e..88921b78802 100644 --- a/sdcm/utils/sstable/s3_uploader.py +++ b/sdcm/utils/sstable/s3_uploader.py @@ -31,7 +31,7 @@ def upload_sstables_to_s3(node: CollectingNode | BaseNode, keyspace: str, test_i if s3_link: LOGGER.info("Successfully uploaded sstables on node %s for keyspace %s", node.name, keyspace) node.remoter.run(f"nodetool clearsnapshot -t {snapshot_tag} {keyspace}") - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Error while getting and uploading sstables: %s", exc, exc_info=exc) s3_link = "" return s3_link diff --git a/sdcm/utils/threads_and_processes_alive.py b/sdcm/utils/threads_and_processes_alive.py index 3721ef54bd9..e939b76312c 100644 --- a/sdcm/utils/threads_and_processes_alive.py +++ b/sdcm/utils/threads_and_processes_alive.py @@ -20,7 +20,7 @@ def get_thread_stacktrace(thread): # pylint: disable=no-self-use if line: output.append(" %s" % (line.strip())) return '\n'.join(output) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error('Failed to get stack trace due to the: %s', exc) return 'FAILED TO GET STACKTRACE' @@ -28,7 +28,7 @@ def get_thread_stacktrace(thread): # pylint: disable=no-self-use def get_source(source: Any): try: return inspect.getsource(source) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error('Failed to source due to the: %s', exc) return 'NO SOURCE AVAILABLE' diff --git a/sdcm/utils/version_utils.py b/sdcm/utils/version_utils.py index e13522bab28..3f6df7f090c 100644 --- a/sdcm/utils/version_utils.py +++ b/sdcm/utils/version_utils.py @@ -747,7 +747,7 @@ def get_relocatable_pkg_url(scylla_version: str) -> str: get_pkgs_cmd = f'curl -s -X POST http://backtrace.scylladb.com/index.html -d "build_id={scylla_build_id}&backtrace="' res = LOCALRUNNER.run(get_pkgs_cmd) relocatable_pkg = re.findall(fr"{scylla_build_id}.+(http:[/\w.:-]*\.tar\.gz)", res.stdout)[0] - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.warning("Couldn't get relocatable_pkg link due to: %s", exc) return relocatable_pkg diff --git a/sdcm/wait.py b/sdcm/wait.py index d7bb84f46ee..811d9071c39 100644 --- a/sdcm/wait.py +++ b/sdcm/wait.py @@ -69,7 +69,7 @@ def retry_logger(retry_state): ) res = retry(func, **kwargs) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 err = f"Wait for: {text or func.__name__}: timeout - {timeout} seconds - expired" raising_exc = WaitForTimeoutError(err) if stop_event and stop_event.is_set(): diff --git a/sla_per_user_system_test.py b/sla_per_user_system_test.py index 758da53882b..2224548a6f3 100644 --- a/sla_per_user_system_test.py +++ b/sla_per_user_system_test.py @@ -884,13 +884,13 @@ def get_email_data(self): try: email_data = self._get_common_email_data() - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Error in gathering common email data: Error:\n%s", error) try: grafana_dataset = self.monitors.get_grafana_screenshot_and_snapshot( self.start_time) if self.monitors else {} - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Error in gathering Grafana screenshots and snapshots. Error:\n%s", error) email_data.update({"grafana_screenshots": grafana_dataset.get("screenshots", []), diff --git a/stop_compaction_test.py b/stop_compaction_test.py index 8d2d0c87696..6774c2c0739 100644 --- a/stop_compaction_test.py +++ b/stop_compaction_test.py @@ -38,7 +38,7 @@ def wrapper(*args, **kwargs): try: func(*args, **kwargs) return {test_name: ["SUCCESS", []]} - except Exception as exc: # pylint:disable=broad-except + except Exception as exc: # pylint:disable=broad-except # noqa: BLE001 LOGGER.error(exc) return {test_name: ["FAILURE", [exc]]} return wrapper @@ -375,7 +375,7 @@ def get_email_data(self): try: email_data = self._get_common_email_data() - except Exception as error: # pylint: disable=broad-except + except Exception as error: # pylint: disable=broad-except # noqa: BLE001 self.log.error("Error in gathering common email data: Error:\n%s", error) email_data.update({"test_statuses": self.test_statuses, diff --git a/unit_tests/conftest.py b/unit_tests/conftest.py index 202ba8d7a0f..a098c31e734 100644 --- a/unit_tests/conftest.py +++ b/unit_tests/conftest.py @@ -91,14 +91,14 @@ def fixture_docker_scylla(request: pytest.FixtureRequest): # pylint: disable=to def db_up(): try: return scylla.is_port_used(port=BaseNode.CQL_PORT, service_name="scylla-server") - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 logging.error("Error checking for scylla up normal: %s", details) return False def db_alternator_up(): try: return scylla.is_port_used(port=8000, service_name="scylla-server") - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 logging.error("Error checking for scylla up normal: %s", details) return False diff --git a/unit_tests/test_coredump.py b/unit_tests/test_coredump.py index 7d4705e27f7..85aec47de99 100644 --- a/unit_tests/test_coredump.py +++ b/unit_tests/test_coredump.py @@ -108,7 +108,7 @@ def _run_coredump_with_fake_remoter(self, test_name: str): result_coredump_list = results[coredump_status] try: self.assertEqual(expected_coredump_list, result_coredump_list) - except Exception as exc: + except Exception as exc: # noqa: BLE001 raise AssertionError( f'Got unexpected results for {coredump_status}: {str(result_coredump_list)}\n{str(exc)}') from exc diff --git a/unit_tests/test_events.py b/unit_tests/test_events.py index f4a399c1a51..1b79fee9eab 100644 --- a/unit_tests/test_events.py +++ b/unit_tests/test_events.py @@ -785,7 +785,7 @@ def test_kill_nemesis_during_con_event(self): nemesis_event.duration = 15 raise - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pytest.fail("we shouldn't reach this code path") assert nemesis_event.errors_formatted == '' diff --git a/unit_tests/test_remoter.py b/unit_tests/test_remoter.py index d5ff351a677..f4db11bcdbf 100644 --- a/unit_tests/test_remoter.py +++ b/unit_tests/test_remoter.py @@ -98,12 +98,12 @@ def _create_and_run_twice_in_same_thread(remoter_type, key_file, stmt, kwargs, p pod_name='sct-cluster-dc-1-kind-0', container="scylla", namespace="scylla") try: result = remoter.run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 result = exc paramiko_thread_results.append(result) try: result = remoter.run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 result = exc paramiko_thread_results.append(result) remoter.stop() @@ -120,13 +120,13 @@ def _create_and_run_in_same_thread(remoter_type, host, key_file, stmt, kwargs, p pod_name='sct-cluster-dc-1-kind-0', container="scylla", namespace="scylla") try: result = remoter.run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 result = exc paramiko_thread_results.append(result) remoter._reconnect() # pylint: disable=protected-access try: result = remoter.run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 result = exc paramiko_thread_results.append(result) remoter.stop() @@ -135,13 +135,13 @@ def _create_and_run_in_same_thread(remoter_type, host, key_file, stmt, kwargs, p def _create_and_run_in_separate_thread(remoter, stmt, kwargs, paramiko_thread_results): try: result = remoter.run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 result = exc paramiko_thread_results.append(result) remoter._reconnect() # pylint: disable=protected-access try: result = remoter.run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 result = exc paramiko_thread_results.append(result) remoter.stop() @@ -211,7 +211,7 @@ def test_run_in_mainthread( # pylint: disable=too-many-arguments 'timeout': timeout} try: expected = LocalCmdRunner().run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 expected = exc if issubclass(remoter_type, (RemoteCmdRunner, RemoteLibSSH2CmdRunner)): @@ -223,12 +223,12 @@ def test_run_in_mainthread( # pylint: disable=too-many-arguments pod_name='sct-cluster-dc-1-kind-0', container="scylla", namespace="scylla") try: result = remoter.run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 result = exc remoter._reconnect() # pylint: disable=protected-access try: result2 = remoter.run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 result2 = exc remoter.stop() @@ -249,7 +249,7 @@ def test_create_and_run_in_same_thread( # pylint: disable=too-many-arguments,to self.log.info(repr({stmt: stmt, **kwargs})) try: expected = LocalCmdRunner().run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 expected = exc paramiko_thread_results = [] @@ -276,7 +276,7 @@ def test_create_and_run_in_separate_thread( # pylint: disable=too-many-argument self.log.info(repr({stmt: stmt, **kwargs})) try: expected = LocalCmdRunner().run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 expected = exc # Paramiko fails too often when it is invoked like that, that is why it is not in the test @@ -332,7 +332,7 @@ def test_load_1000_threads(self, remoter_type, stmt: str): self.log.info(repr({stmt: stmt, **kwargs})) try: expected = LocalCmdRunner().run(stmt, **kwargs) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 expected = exc libssh2_thread_results = [] diff --git a/unit_tests/test_sct_events_loaders.py b/unit_tests/test_sct_events_loaders.py index e795758506c..14df1b2ee7d 100644 --- a/unit_tests/test_sct_events_loaders.py +++ b/unit_tests/test_sct_events_loaders.py @@ -187,7 +187,7 @@ def test_continuous_event_with_error(self): try: raise ValueError('Stress command completed with bad status 1') - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 scylla_bench_event.severity = Severity.ERROR scylla_bench_event.add_error([str(exc)]) diff --git a/unit_tests/test_tester.py b/unit_tests/test_tester.py index 49cd179d599..8c2e606c9e1 100644 --- a/unit_tests/test_tester.py +++ b/unit_tests/test_tester.py @@ -213,7 +213,7 @@ def test(): end_time = time.time() + 2 while time.time() < end_time: time.sleep(0.1) - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass def _validate_results(self): diff --git a/upgrade_test.py b/upgrade_test.py index 58a9a8f19fd..e72746cd6e8 100644 --- a/upgrade_test.py +++ b/upgrade_test.py @@ -24,6 +24,8 @@ from typing import List import contextlib +import cassandra +import tenacity from argus.client.sct.types import Package from cassandra import ConsistencyLevel from cassandra.query import SimpleStatement # pylint: disable=no-name-in-module @@ -66,7 +68,7 @@ def inner(self, *args, **kwargs): try: self.cql_truncate_simple_tables(session=session, rows=NUMBER_OF_ROWS_FOR_TRUNCATE_TEST) InfoEvent(message="Finish truncate simple tables").publish() - except Exception as details: # pylint: disable=broad-except + except cassandra.DriverException as details: InfoEvent(message=f"Failed truncate simple tables. Error: {str(details)}. Traceback: {traceback.format_exc()}", severity=Severity.ERROR).publish() self.validate_truncated_entries_for_table(session=session, system_truncated=True) @@ -166,7 +168,7 @@ def read_data_from_truncated_tables(self, session): msg='Expected that there is no data in the table truncate_ks.{}, but found {} rows' .format(table_name, count[0][0])) InfoEvent(message=f"Finish read data from {table_name} tables").publish() - except Exception as details: # pylint: disable=broad-except + except Exception as details: # pylint: disable=broad-except # noqa: BLE001 InfoEvent(message=f"Failed read data from {table_name} tables. Error: {str(details)}. Traceback: {traceback.format_exc()}", severity=Severity.ERROR).publish() @@ -497,7 +499,7 @@ def wait_for_node_to_finish(): assert list(sstable_versions)[0] == self.expected_sstable_format_version, ( "expected to format version to be '{}', found '{}'".format( self.expected_sstable_format_version, list(sstable_versions)[0])) - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: # pylint: disable=broad-except # noqa: BLE001 self.log.warning(ex) return False else: @@ -507,7 +509,7 @@ def wait_for_node_to_finish(): InfoEvent(message="Start waiting for upgardesstables to finish").publish() wait.wait_for(func=wait_for_node_to_finish, step=30, timeout=900, throw_exc=True, text="Waiting until upgardesstables is finished") - except Exception: # pylint: disable=broad-except + except tenacity.RetryError: all_tables_upgraded = False finally: if queue: @@ -1404,7 +1406,7 @@ def _custom_profile_rolling_upgrade(self, cs_user_profiles, new_scylla_repo=None try: self.metric_has_data( metric_query='sct_cassandra_stress_user_gauge{type="ops", keyspace="%s"}' % keyspace_name, n=10) - except Exception as err: # pylint: disable=broad-except + except Exception as err: # pylint: disable=broad-except # noqa: BLE001 InfoEvent( f"Get metrix data for keyspace {keyspace_name} failed with error: {err}", severity=Severity.ERROR).publish() diff --git a/utils/cloud_cleanup/aws/clean_aws.py b/utils/cloud_cleanup/aws/clean_aws.py index e7f2c41b7bc..77999f6330e 100644 --- a/utils/cloud_cleanup/aws/clean_aws.py +++ b/utils/cloud_cleanup/aws/clean_aws.py @@ -100,7 +100,7 @@ def stop_instance(instance): } ]) instance.stop() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 eprint("stop instance %s error: %s" % (instance.id, str(exc))) @@ -113,7 +113,7 @@ def remove_protection(instance): 'Value': False }) print_instance(instance, "Disabling API Termination protection") - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 eprint("DisableApiTermination protection %s error: %s" % (instance.id, str(exc))) @@ -127,7 +127,7 @@ def terminate_instance(instance): } ]) instance.terminate() - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 eprint("terminate instance %s error: %s" % (instance.id, str(exc))) @@ -230,7 +230,7 @@ def delete_volume(volume): print_volume(volume, "deleting") if not DRY_RUN: volume.delete() - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except # noqa: BLE001 pass @@ -281,7 +281,7 @@ def release_address(eip_dict, client): client.release_address(AllocationId=eip_dict['AllocationId']) elif "PublicIp" in eip_dict: client.release_address(PublicIp=eip_dict['PublicIp']) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 print(exc) diff --git a/utils/cloud_cleanup/azure/clean_azure.py b/utils/cloud_cleanup/azure/clean_azure.py index 4fd62fae2e0..dbefde251ff 100755 --- a/utils/cloud_cleanup/azure/clean_azure.py +++ b/utils/cloud_cleanup/azure/clean_azure.py @@ -53,7 +53,7 @@ def get_vm_creation_time(v_m, resource_group_name): compute_client.virtual_machines.begin_update(resource_group_name, v_m.name, parameters={ "tags": tags, }) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.info( "Failed to update VM tags: %s in resource group: %s with exception: %s", v_m.name, resource_group_name, exc) @@ -72,7 +72,7 @@ def get_rg_creation_time(resource_group): resource_group.tags = tags try: resource_client.resource_groups.create_or_update(resource_group.name, resource_group) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.info("Failed to update RG tags: %s with exception: %s", resource_group.name, exc) return creation_time @@ -102,7 +102,7 @@ def delete_virtual_machine(resource_group_name, vm_name, dry_run=False): LOGGER.info("Deleting VM: %s in resource group: %s", vm_name, resource_group_name) try: compute_client.virtual_machines.begin_delete(resource_group_name, vm_name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.info( "Failed to delete VM: %s in resource group: %s with exception: %s", vm_name, resource_group_name, exc) @@ -114,7 +114,7 @@ def stop_virtual_machine(resource_group_name, vm_name, dry_run=False): LOGGER.info("Stopping VM: %s in resource group: %s", vm_name, resource_group_name) try: compute_client.virtual_machines.begin_deallocate(resource_group_name, vm_name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.info("Failed to stop VM: %s in resource group: %s with exception: %s", vm_name, resource_group_name, exc) @@ -126,7 +126,7 @@ def delete_resource_group(resource_group_name, dry_run=False): LOGGER.info("Deleting resource group: %s", resource_group_name) try: resource_client.resource_groups.begin_delete(resource_group_name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.info("Failed to delete resource group: %s with exception: %s", resource_group_name, exc) diff --git a/utils/cloud_cleanup/gce/clean_gce.py b/utils/cloud_cleanup/gce/clean_gce.py index ebaee492fce..4690226c1bf 100644 --- a/utils/cloud_cleanup/gce/clean_gce.py +++ b/utils/cloud_cleanup/gce/clean_gce.py @@ -57,7 +57,7 @@ def clean_gce_instances(instances_client, project_id, dry_run): zone=instance.zone.split('/')[-1]) res.done() LOGGER.info("%s terminated", instance.name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("error while terminating instance %s: %s", instance.name, exc) else: LOGGER.info("dry run: would terminate instance %s, creation time: %s", @@ -72,7 +72,7 @@ def clean_gce_instances(instances_client, project_id, dry_run): zone=instance.zone.split('/')[-1]) res.done() LOGGER.info("%s stopped", instance.name) - except Exception as exc: # pylint: disable=broad-except + except Exception as exc: # pylint: disable=broad-except # noqa: BLE001 LOGGER.error("error while stopping instance %s: %s", instance.name, exc) else: LOGGER.info("dry run: would stop instance %s, creation time: %s", instance.name, vm_creation_time)