Skip to content

Commit

Permalink
print errors on console for execute-test
Browse files Browse the repository at this point in the history
Signed-off-by: Chinmay Gadgil <[email protected]>

added erros file for common opensearch errors during execute-test

Signed-off-by: Chinmay Gadgil <[email protected]>

make errors less verbose

Signed-off-by: Chinmay Gadgil <[email protected]>
  • Loading branch information
cgchinmay committed Nov 27, 2023
1 parent 20d4928 commit 79f2824
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
58 changes: 58 additions & 0 deletions osbenchmark/worker_coordinator/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import re

def parse_error(error_metadata):
error = error_metadata['error']
status_code = None
description = "error occured, check logs for details"

if 'status' in error_metadata:
status_code = error_metadata["status"]

if 'reason' in error:
description = error['reason']
matches = re.findall(r'\[([^]]*)\]', description)
for match in matches:
if match == "indices:admin/create":
return IndexOperationError(description, "index-create", status_code)
elif match == "indices:admin/delete":
return IndexOperationError(description, "index-delete", status_code)
elif match == "indices:data/write/bulk":
return IndexOperationError(description, "index-append", status_code)
elif match == "indices:admin/refresh":
return IndexOperationError(description, "refresh-after-index", status_code)
elif match == "indices:admin/forcemerge":
return IndexOperationError(description, "force-merge", status_code)
elif match == "indices:data/read/search":
return SearchOperationError(description, "search", status_code)

return UnknownOperationError(description, None)


class OpenSearchOperationError():
def __init__(self, description, operation=None, status_code=None):
self.description = description
self.operation = operation
self.status_code = status_code

class UnknownOperationError(OpenSearchOperationError):
def get_error_message(self):
return self.description


class IndexOperationError(OpenSearchOperationError):
def get_error_message(self):
if self.status_code == 403:
return f"permission denied for {self.operation}. check logs for details"
elif self.status_code == 500:
return f"internal server error for {self.operation}. check logs for details"
else:
return self.description

class SearchOperationError(OpenSearchOperationError):
def get_error_message(self):
if self.status_code == 403:
return f"permission denied for {self.operation}. check logs for details"
elif self.status_code == 500:
return f"internal server error for {self.operation} index. check logs for details"
else:
return self.description
16 changes: 15 additions & 1 deletion osbenchmark/worker_coordinator/worker_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import concurrent.futures
import datetime
import itertools
import json
import logging
import math
import multiprocessing
Expand All @@ -44,7 +45,7 @@
from osbenchmark.worker_coordinator import runner, scheduler
from osbenchmark.workload import WorkloadProcessorRegistry, load_workload, load_workload_plugins
from osbenchmark.utils import convert, console, net

from osbenchmark.worker_coordinator.errors import parse_error

##################################
#
Expand Down Expand Up @@ -1690,6 +1691,7 @@ async def execute_single(runner, opensearch, params, on_error):
except KeyError as e:
logging.getLogger(__name__).exception("Cannot execute runner [%s]; most likely due to missing parameters.", str(runner))
msg = "Cannot execute [%s]. Provided parameters are: %s. Error: [%s]." % (str(runner), list(params.keys()), str(e))
console.error(msg)
raise exceptions.SystemSetupError(msg)

if not request_meta_data["success"]:
Expand All @@ -1698,7 +1700,19 @@ async def execute_single(runner, opensearch, params, on_error):
description = request_meta_data.get("error-description")
if description:
msg += ", Description: %s" % description
console.error(msg)
raise exceptions.BenchmarkAssertionError(msg)

if 'error-description' in request_meta_data:
try:
error_metadata = json.loads(request_meta_data["error-description"])
# parse error-description metadata
opensearch_operation_error = parse_error(error_metadata)
console.error(opensearch_operation_error.get_error_message())
except Exception as e:
# error-description is not a valid json so we just print it
console.error(request_meta_data["error-description"])

return total_ops, total_ops_unit, request_meta_data


Expand Down

0 comments on commit 79f2824

Please sign in to comment.