Skip to content

Commit

Permalink
Also needed to fix state and type for requests; Fix #4251 (#4259)
Browse files Browse the repository at this point in the history
* Also needed to fix state and type for requests; Fix #4251

* also fix wrong payload
  • Loading branch information
mlassnig authored and bari12 committed Jan 21, 2021
1 parent 0d388c0 commit 8cf59b1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/rucio/core/request.py
Expand Up @@ -225,17 +225,18 @@ def temp_serializer(obj):
'is_using': source['is_using']})

if request['request_type']:
transfer_status = '%s-%s' % (request['request_type'], request['state'])
transfer_status = '%s-%s' % (request['request_type'].name, request['state'].name)
else:
transfer_status = 'transfer-%s' % request['state']
transfer_status = 'transfer-%s' % request['state'].name
transfer_status = transfer_status.lower()

payload = {'request-id': new_request['id'],
'request-type': str(request['request_type']).lower(),
'request-type': request['request_type'].name.lower(),
'scope': request['scope'].external,
'name': request['name'],
'dst-rse-id': request['dest_rse_id'],
'dst-rse': dest_rse_name,
'state': str(request['state']),
'state': request['state'].name.lower(),
'retry-count': request['retry_count'],
'rule-id': str(request['rule_id']),
'activity': request['attributes']['activity'],
Expand All @@ -245,7 +246,7 @@ def temp_serializer(obj):
'checksum-adler': request['attributes']['adler32'],
'queued_at': str(datetime.datetime.utcnow())}

messages.append({'event_type': transfer_status.lower(),
messages.append({'event_type': transfer_status,
'payload': json.dumps(payload)})

for requests_chunk in chunks(new_requests, 1000):
Expand Down Expand Up @@ -1336,9 +1337,9 @@ def add_monitor_message(request, response, session=None):
"""

if request['request_type']:
transfer_status = '%s-%s' % (request['request_type'], response['new_state'])
transfer_status = '%s-%s' % (request['request_type'].name, response['new_state'].name)
else:
transfer_status = 'transfer-%s' % (response['new_state'])
transfer_status = 'transfer-%s' % (response['new_state'].name)
transfer_status = transfer_status.lower()

activity = response.get('activity', None)
Expand Down

0 comments on commit 8cf59b1

Please sign in to comment.