Repository: rucio/rucio

Issue:
json schema validation causes a lot of entries in the logfile
Motivation
----------
The json schema validation being performed here:
https://github.com/rucio/rucio/blob/5ed6e6b78196afbb5650e217a3b28687e492aa2a/lib/rucio/core/trace.py#L272-L286 

fails for certain json schemas defined in the same file.

This prevents the traces from being sent to ActiveMQ and they are logged as errors instead. As a result, the log sizes have become threefold.

Here's logs from one of the httpd servers running in the pods, that can help debug the issue:

```
[Thu Dec 02 16:26:54.803499 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468] Failed validating 'required' in schema:
[Thu Dec 02 16:26:54.803502 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]     {'description': 'get method, mainly sent by pilots',
[Thu Dec 02 16:26:54.803504 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'properties': {'clientState': {'description': 'Client state',
[Thu Dec 02 16:26:54.803523 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                     'enum': ['DONE',
[Thu Dec 02 16:26:54.803526 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                              'FAILED',
[Thu Dec 02 16:26:54.803528 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                              'PROCESSING',
[Thu Dec 02 16:26:54.803531 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                              'ALREADY_DONE',
[Thu Dec 02 16:26:54.803540 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                              'FILE_NOT_FOUND',
[Thu Dec 02 16:26:54.803542 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                              'FOUND_IN_PCACHE',
[Thu Dec 02 16:26:54.803545 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                              'DOWNLOAD_ATTEMPT',
[Thu Dec 02 16:26:54.803548 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                              'FAIL_VALIDATE',
[Thu Dec 02 16:26:54.803551 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                              'FOUND_ROOT'],
[Thu Dec 02 16:26:54.803554 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                     'type': 'string'},
[Thu Dec 02 16:26:54.803556 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'dataset': {'type': 'string'},
[Thu Dec 02 16:26:54.803559 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'datasetScope': {'type': 'string'},
[Thu Dec 02 16:26:54.803562 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'eventType': {'enum': ['get',
[Thu Dec 02 16:26:54.803565 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                            'get_sm',
[Thu Dec 02 16:26:54.803568 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                            'sm_get',
[Thu Dec 02 16:26:54.803570 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                            'get_sm_a',
[Thu Dec 02 16:26:54.803573 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                            'sm_get_a']},
[Thu Dec 02 16:26:54.803576 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'eventVersion': {'type': 'string'},
[Thu Dec 02 16:26:54.803579 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'filename': {'type': 'string'},
[Thu Dec 02 16:26:54.803594 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'name': {'type': 'string'},
[Thu Dec 02 16:26:54.803598 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'remoteSite': {'description': 'RSE name',
[Thu Dec 02 16:26:54.803600 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                    'pattern': '^([A-Z0-9]+([_-][A-Z0-9]+)*)$',
[Thu Dec 02 16:26:54.803603 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                    'type': 'string'},
[Thu Dec 02 16:26:54.803606 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'scope': {'description': 'Scope name',
[Thu Dec 02 16:26:54.803609 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                               'pattern': '^[a-zA-Z_\\\\-.0-9]{1,25}$',
[Thu Dec 02 16:26:54.803612 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                               'type': 'string'},
[Thu Dec 02 16:26:54.803615 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'stateReason': {'type': 'string'},
[Thu Dec 02 16:26:54.803617 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'traceId': {'description': 'Universally Unique '
[Thu Dec 02 16:26:54.803620 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                                'Identifier (UUID)',
[Thu Dec 02 16:26:54.803623 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                 'pattern': '^(\\\\{){0,1}[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}(\\\\}){0,1}$',
[Thu Dec 02 16:26:54.803626 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                 'type': 'string'},
[Thu Dec 02 16:26:54.803629 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'traceIp': {'description': 'Internet Protocol address '
[Thu Dec 02 16:26:54.803632 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                                'v4, RFC 791',
[Thu Dec 02 16:26:54.803635 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                 'pattern': '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\\\.|$)){4}$',
[Thu Dec 02 16:26:54.803638 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                 'type': 'string'},
[Thu Dec 02 16:26:54.803641 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'traceTimeentry': {'description': 'Datetime, ISO 8601',
[Thu Dec 02 16:26:54.803644 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                        'pattern': '^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}.\\\\d*$',
[Thu Dec 02 16:26:54.803646 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                                        'type': 'string'},
[Thu Dec 02 16:26:54.803649 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'traceTimeentryUnix': {'type': 'number'},
[Thu Dec 02 16:26:54.803652 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'url': {'type': 'string'},
[Thu Dec 02 16:26:54.803655 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'usrdn': {'type': 'string'},
[Thu Dec 02 16:26:54.803658 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                     'vo': {'type': 'string'}},
[Thu Dec 02 16:26:54.803661 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'required': ['hostname',
[Thu Dec 02 16:26:54.803666 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'eventType',
[Thu Dec 02 16:26:54.803668 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'localSite',
[Thu Dec 02 16:26:54.803671 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'account',
[Thu Dec 02 16:26:54.803674 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'eventType',
[Thu Dec 02 16:26:54.803676 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'eventVersion',
[Thu Dec 02 16:26:54.803679 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'uuid',
[Thu Dec 02 16:26:54.803682 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'scope',
[Thu Dec 02 16:26:54.803685 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'filename',
[Thu Dec 02 16:26:54.803687 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'datasetScope',
[Thu Dec 02 16:26:54.803690 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'dataset',
[Thu Dec 02 16:26:54.803693 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'filesize',
[Thu Dec 02 16:26:54.803695 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'clientState',
[Thu Dec 02 16:26:54.803698 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]                   'stateReason'],
[Thu Dec 02 16:26:54.803701 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'type': 'object'}
[Thu Dec 02 16:26:54.803703 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]
[Thu Dec 02 16:26:54.803706 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468] On instance:
[Thu Dec 02 16:26:54.803709 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]     {'appid': 'redacted',
[Thu Dec 02 16:26:54.803711 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'catStart': redacted,
[Thu Dec 02 16:26:54.803714 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'clientState': 'DONE',
[Thu Dec 02 16:26:54.803717 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'dataset': 'redacted',
[Thu Dec 02 16:26:54.803720 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'duid': None,
[Thu Dec 02 16:26:54.803723 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'eventType': 'redacted',
[Thu Dec 02 16:26:54.803726 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'eventVersion': 'redacted',
[Thu Dec 02 16:26:54.803729 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'filename': 'redacted',
[Thu Dec 02 16:26:54.803731 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'filesize': redacted,
[Thu Dec 02 16:26:54.803734 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'guid': 'redacted',
[Thu Dec 02 16:26:54.803737 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'hostname': 'redacted',
[Thu Dec 02 16:26:54.803740 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'ip': 'redacted',
[Thu Dec 02 16:26:54.803742 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'localSite': 'redacted',
[Thu Dec 02 16:26:54.803745 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'pq': 'redacted,
[Thu Dec 02 16:26:54.803752 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'protocol': 'redacted',
[Thu Dec 02 16:26:54.803755 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'relativeStart': 1638462384.2915378,
[Thu Dec 02 16:26:54.803758 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'remoteSite': 'redacted',
[Thu Dec 02 16:26:54.803761 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'scope': 'redacted',
[Thu Dec 02 16:26:54.803763 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'stateReason': 'OK',
[Thu Dec 02 16:26:54.803766 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'suspicious': '0',
[Thu Dec 02 16:26:54.803769 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'taskid': 'redacted',
[Thu Dec 02 16:26:54.803771 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'timeEnd': redacted,
[Thu Dec 02 16:26:54.803774 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'timeStart': redacted,
[Thu Dec 02 16:26:54.803777 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'traceId': 'redacted',
[Thu Dec 02 16:26:54.803779 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'traceIp': 'redacted',
[Thu Dec 02 16:26:54.803782 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'traceTimeentry': 'redacted',
[Thu Dec 02 16:26:54.803785 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'traceTimeentryUnix': redacted,
[Thu Dec 02 16:26:54.803788 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'transferStart': redacted,
[Thu Dec 02 16:26:54.803791 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'url': 'redacted',
[Thu Dec 02 16:26:54.803794 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'usr': 'redacted',
[Thu Dec 02 16:26:54.803796 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'usrdn': 'redacted',
[Thu Dec 02 16:26:54.803799 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'uuid': 'redacted',
[Thu Dec 02 16:26:54.803802 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'validateStart': redacted,
[Thu Dec 02 16:26:54.803807 2021] [wsgi:error] [pid 22:tid 140415126062848] [remote 10.100.74.0:56468]      'version': None}
```
Modification
------------

remove the following fields from the definition of `GET_SCHEMA`'s required section:
`['hostname', 'account', 'datasetScope', 'filesize', 'clientState', 'stateReason']`

so that the required section contains only the following fields:
`['eventType', 'localSite', 'eventType', 'eventVersion', 'uuid', 'scope', 'filename', 'dataset']`



Discussion:

Resolving patch:
diff --git a/lib/rucio/core/trace.py b/lib/rucio/core/trace.py
--- a/lib/rucio/core/trace.py
+++ b/lib/rucio/core/trace.py
@@ -22,6 +22,7 @@
 # - Benedikt Ziemons <benedikt.ziemons@cern.ch>, 2020-2021
 # - Martin Barisits <martin.barisits@cern.ch>, 2021
 # - David Población Criado <david.poblacion.criado@cern.ch>, 2021
+# - Mayank Sharma <mayank.sharma@cern.ch>, 2021
 
 """
 Core tracer module
@@ -190,8 +191,8 @@
         "traceId": UUID,
         "usrdn": {"type": "string"},
     },
-    "required": ['hostname', 'eventType', 'localSite', 'account', 'eventType', 'eventVersion', 'uuid', 'scope',
-                 'filename', 'datasetScope', 'dataset', 'filesize', 'clientState', 'stateReason']
+    "required": ['eventType', 'localSite', 'eventVersion', 'uuid', 'scope',
+                 'filename', 'dataset']
 }
 
 SCHEMAS = {


Test patch: