From 689c67155124264e6157982605a59273b6da1ccb Mon Sep 17 00:00:00 2001 From: Filip Valder Date: Fri, 3 Mar 2017 11:23:00 +0100 Subject: [PATCH] Retry until we get build containing xmd data. --- module_build_service/scheduler/handlers/modules.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/module_build_service/scheduler/handlers/modules.py b/module_build_service/scheduler/handlers/modules.py index d393c8c8..c398c006 100644 --- a/module_build_service/scheduler/handlers/modules.py +++ b/module_build_service/scheduler/handlers/modules.py @@ -121,7 +121,19 @@ def wait(config, session, msg): The kicking off of individual component builds is handled elsewhere, in module_build_service.schedulers.handlers.repos. """ - build = models.ModuleBuild.from_module_event(session, msg) + + # Wait for the db on the frontend to catch up to the message, otherwise the + # xmd information won't be present when we need it. + # See https://pagure.io/fm-orchestrator/issue/386 + @module_build_service.utils.retry(interval=2, timeout=30, wait_on=RuntimeError) + def _get_build_containing_xmd_for_mbs(): + build = models.ModuleBuild.from_module_event(session, msg) + if 'mbs' in build.mmd().xmd: + return build + raise RuntimeError("{!r} doesn't contain xmd information for MBS." + .format(build)) + + build = _get_build_containing_xmd_for_mbs() log.info("Found build=%r from message" % build) module_info = build.json()