From: Arif Hussain Date: Thu, 9 Dec 2021 16:01:31 +0000 (+0530) Subject: Need to report an error back to the producer of VES events X-Git-Tag: 6.0.2~33 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F88%2F7288%2F3;p=smo%2Fves.git Need to report an error back to the producer of VES events Signed-off-by: Arif Hussain Change-Id: Id57f9c72671f4c640ba91542338a010ec7854da7 Signed-off-by: Arif Hussain --- diff --git a/collector/evel-test-collector/code/collector/monitor.py b/collector/evel-test-collector/code/collector/monitor.py index 60a04f0..de54891 100755 --- a/collector/evel-test-collector/code/collector/monitor.py +++ b/collector/evel-test-collector/code/collector/monitor.py @@ -224,7 +224,8 @@ def listener(environ, start_response, schema): except jsonschema.SchemaError as e: logger.error('Schema is not valid! {0}'.format(e)) - + # Stop container forcefully. + os._exit(0) except jsonschema.ValidationError as e: logger.warn('Event is not valid against schema! {0}'.format(e)) logger.warn('Bad JSON body decoded:\n' @@ -232,9 +233,14 @@ def listener(environ, start_response, schema): sort_keys=True, indent=4, separators=(',', ': ')))) - + start_response('400 Bad Request', + [('Content-type', 'application/json')]) + yield ''.encode() except Exception as e: logger.error('Event invalid for unexpected reason! {0}'.format(e)) + start_response('500 Internal Server Error', + [('Content-type', 'application/json')]) + yield ''.encode() else: logger.debug('No schema so just decode JSON: {0}'.format(body)) try: