From e7eb81357842cda8c869318078dd89bbd7231672 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Mon, 13 Oct 2014 20:04:29 +0000 Subject: [PATCH] Scrub problematic fields from koji fedmsg messages. --- roles/koji_hub/files/fedmsg-koji-plugin.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/roles/koji_hub/files/fedmsg-koji-plugin.py b/roles/koji_hub/files/fedmsg-koji-plugin.py index 2cace88fc7..5944017c9c 100644 --- a/roles/koji_hub/files/fedmsg-koji-plugin.py +++ b/roles/koji_hub/files/fedmsg-koji-plugin.py @@ -143,4 +143,20 @@ def send_message(cbtype, *args, **kws): # and the secondary hubs off for s390 and ppc. body['instance'] = 'primary' + # Last thing to do before publishing: scrub some problematic fields + # These fields are floating points which get json-encoded differently on + # rhel and fedora. + problem_fields = ['weight', 'start_ts', 'create_ts', 'completion_ts'] + def scrub(obj): + if not isinstance(obj, dict): + return + for key in obj: + if key in problem_fields: + del obj[key] + if isinstance(obj[key], list): + [scrub(item) for item in obj] + if isinstance(obj[key], dict): + [scrub(obj[key]) for key in obj] + scrub(body) + fedmsg.publish(topic=topic, msg=body, modname='buildsys')