Skip to content

Commit

Permalink
Revert "fix(FullScan): rename forward_service to mapreduce_service"
Browse files Browse the repository at this point in the history
This reverts commit ab00b95.
This change is not part of enterprise branch.
  • Loading branch information
soyacz committed Nov 19, 2024
1 parent 4303ecb commit aa7b944
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions sdcm/scan_operation_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def execute_query(self, session, cmd: str,
event: Type[FullScanEvent | FullPartitionScanEvent
| FullPartitionScanReversedOrderEvent]) -> None:
self.log.debug('Will run command %s', cmd)
validate_mapreduce_service_requests_start_time = time.time()
validate_forward_service_requests_start_time = time.time()
try:
cmd_result = session.execute(
query=cmd, trace=False, timeout=self._session_execution_timeout)
Expand All @@ -483,15 +483,15 @@ def execute_query(self, session, cmd: str,
event.severity = Severity.ERROR
return

message, severity = self._validate_fullscan_result(cmd_result, validate_mapreduce_service_requests_start_time)
message, severity = self._validate_fullscan_result(cmd_result, validate_forward_service_requests_start_time)
if not severity:
event.message = f"{type(self).__name__} operation ended successfully: {message}"
else:
event.severity = severity
event.message = f"{type(self).__name__} operation failed: {message}"

def _validate_fullscan_result(
self, cmd_result: ResultSet, validate_mapreduce_service_requests_start_time):
self, cmd_result: ResultSet, validate_forward_service_requests_start_time):
result = cmd_result.all()

if not result:
Expand All @@ -504,36 +504,36 @@ def _validate_fullscan_result(
self.log.debug("Fullscan aggregation result: %s", output)

try:
self.validate_mapreduce_service_requests_dispatched_to_other_nodes(
validate_mapreduce_service_requests_start_time)
self.validate_forward_service_requests_dispatched_to_other_nodes(
validate_forward_service_requests_start_time)
except Retry as retry_exception:
self.log.debug("prometheus_mapreduce_service_requests metrics:\n %s",
self.log.debug("prometheus_forward_service_requests metrics:\n %s",
str(retry_exception))
self.log.debug("Fullscan aggregation result: %s", output)
return "Fullscan failed - 'mapreduce_service_requests_dispatched_to_other_nodes' was not triggered", \
return "Fullscan failed - 'forward_service_requests_dispatched_to_other_nodes' was not triggered", \
Severity.ERROR

return f'result {result[0]}', None

@retrying(n=6, sleep_time=10, allowed_exceptions=(Retry, ))
def validate_mapreduce_service_requests_dispatched_to_other_nodes(self, start_time):
def validate_forward_service_requests_dispatched_to_other_nodes(self, start_time):
prometheus = PrometheusDBStats(
TestConfig().tester_obj().monitors.nodes[0].external_address)
prometheus_mapreduce_service_requests = prometheus.query(
'scylla_mapreduce_service_requests_dispatched_to_other_nodes',
prometheus_forward_service_requests = prometheus.query(
'scylla_forward_service_requests_dispatched_to_other_nodes',
start_time, time.time())

# expected format is :
# [{'metric': {'__name__': 'scylla_mapreduce_service_requests_dispatched_to_other_nodes',
# [{'metric': {'__name__': 'scylla_forward_service_requests_dispatched_to_other_nodes',
# 'instance': '10.4.0.181', 'job': 'scylla', 'shard': '0'}, 'values': [[1690287334.763, '0']]}, ...]
for metric in prometheus_mapreduce_service_requests:
mapreduce_service_requests_dispatched_before_query = int(metric["values"][0][1])
mapreduce_service_requests_dispatched_after_query = int(metric["values"][-1][1])
if mapreduce_service_requests_dispatched_before_query < mapreduce_service_requests_dispatched_after_query:
self.log.info('mapreduce_service_requests_dispatched_to_other_nodes was triggered')
for metric in prometheus_forward_service_requests:
forward_service_requests_dispatched_before_query = int(metric["values"][0][1])
forward_service_requests_dispatched_after_query = int(metric["values"][-1][1])
if forward_service_requests_dispatched_before_query < forward_service_requests_dispatched_after_query:
self.log.info('forward_service_requests_dispatched_to_other_nodes was triggered')
return

raise Retry(prometheus_mapreduce_service_requests)
raise Retry(prometheus_forward_service_requests)


class PagedResultHandler:
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/test_scan_operation_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_negative_prometheus_validation_error(events, cluster):
all_events = get_event_log_file(events)
assert "Severity.NORMAL" in all_events[0] and "period_type=begin" in all_events[0]
assert "Severity.ERROR" in all_events[1] and "period_type=end" in all_events[
1] and "Fullscan failed - 'mapreduce_service_requests_dispatched_to_other_nodes' was not triggered" in all_events[1]
1] and "Fullscan failed - 'forward_service_requests_dispatched_to_other_nodes' was not triggered" in all_events[1]


class ExecuteOperationTimedOutMockCqlConnectionPatient(MockCqlConnectionPatient):
Expand Down

0 comments on commit aa7b944

Please sign in to comment.