diff --git a/defaults/severities.yaml b/defaults/severities.yaml index 86ce7f3109..3bd7773ee5 100644 --- a/defaults/severities.yaml +++ b/defaults/severities.yaml @@ -10,6 +10,7 @@ DataValidatorEvent.ImmutableRowsValidator: ERROR DataValidatorEvent.UpdatedRowsValidator: WARNING DataValidatorEvent.DeletedRowsValidator: ERROR ScyllaHelpErrorEvent.duplicate: ERROR +ScyllaHelpErrorEvent.filtered: ERROR FullScanEvent.start: NORMAL FullScanEvent.finish: ERROR DatabaseLogEvent.NO_SPACE_ERROR: ERROR diff --git a/sdcm/cluster.py b/sdcm/cluster.py index 6ff395eca9..1ed61bb5a0 100644 --- a/sdcm/cluster.py +++ b/sdcm/cluster.py @@ -1763,7 +1763,12 @@ def config_setup(self, message=f"Scylla help contains duplicate for the following arguments: {','.join(dups)}" ).publish() ) - append_scylla_args = scylla_arg_parser.filter_args(append_scylla_args) + append_scylla_args = scylla_arg_parser.filter_args( + append_scylla_args, + unknown_args_cb=lambda args: ScyllaHelpErrorEvent.filtered( + message="Following arguments are filtered out: " + ','.join(args) + ).publish() + ) if self.parent_cluster.params.get('db_nodes_shards_selection') == 'random': append_scylla_args += f" --smp {self.scylla_random_shards()}" diff --git a/sdcm/sct_events/database.py b/sdcm/sct_events/database.py index a8b770a064..b04ef9a626 100644 --- a/sdcm/sct_events/database.py +++ b/sdcm/sct_events/database.py @@ -157,6 +157,7 @@ def add_info(self: T_log_event, node, line: str, line_number: int) -> T_log_even class ScyllaHelpErrorEvent(SctEvent, abstract=True): duplicate: Type[SctEventProtocol] + filtered: Type[SctEventProtocol] message: str def __init__(self, message: Optional[str] = None, severity=Severity.ERROR): @@ -175,6 +176,7 @@ def msgfmt(self): ScyllaHelpErrorEvent.add_subevent_type("duplicate") +ScyllaHelpErrorEvent.add_subevent_type("filtered") class FullScanEvent(SctEvent, abstract=True): diff --git a/sdcm/utils/scylla_args.py b/sdcm/utils/scylla_args.py index a556f4daee..025c6689d0 100644 --- a/sdcm/utils/scylla_args.py +++ b/sdcm/utils/scylla_args.py @@ -59,10 +59,10 @@ def from_scylla_help(cls, help: Text, duplicate_cb: Callable = None) -> "ScyllaA return parser - def filter_args(self, args: str) -> str: + def filter_args(self, args: str, unknown_args_cb: Callable = None) -> str: parsed_args, unknown_args = self.parse_known_args(args.split()) - if unknown_args: - LOGGER.warning("Following arguments are filtered out: %s", unknown_args) + if unknown_args and unknown_args_cb: + unknown_args_cb(unknown_args) filtered_args = [] for arg, val in vars(parsed_args).items(): filtered_args.append(f"--{arg.replace('_', '-')}") diff --git a/unit_tests/test_utils_scylla_args.py b/unit_tests/test_utils_scylla_args.py index 5c1b2f6f74..ad63679fd7 100644 --- a/unit_tests/test_utils_scylla_args.py +++ b/unit_tests/test_utils_scylla_args.py @@ -44,8 +44,13 @@ def test_double_args(self): ) def test_filter_args(self): - self.assertEqual(self.parser.filter_args("--arg1 arg --version -W arg --arg2 -h --options-file arg"), - "--version --workdir arg --help --options-file arg") + self.assertEqual( + self.parser.filter_args( + "--arg1 arg --version -W arg --arg2 -h --options-file arg", + unknown_args_cb=lambda args: self.assertEqual(['--arg1', 'arg', '--arg2'], args) + ), + "--version --workdir arg --help --options-file arg", + ) def test_filter_args_unchanged(self): args = "--version --workdir arg --help --options-file arg"