diff --git a/src/cmd-sign b/src/cmd-sign index 3516319cf6..92cc75fef3 100755 --- a/src/cmd-sign +++ b/src/cmd-sign @@ -30,6 +30,9 @@ from gi.repository import GLib, Gio, OSTree # this is really the worst case scenario, it's usually pretty fast otherwise ROBOSIGNATORY_REQUEST_TIMEOUT_SEC = 60 * 60 +# https://pagure.io/fedora-infrastructure/issue/10899#comment-854645 +ROBOSIGNATORY_MESSAGE_PRIORITY = 4 + fedenv = 'prod' @@ -123,6 +126,7 @@ def robosign_ostree(args, s3, build, gpgkey): request_type='ostree-sign', config=args.fedmsg_conf, request_timeout=ROBOSIGNATORY_REQUEST_TIMEOUT_SEC, + priority=ROBOSIGNATORY_MESSAGE_PRIORITY, environment=fedenv, body={ 'build_id': args.build, @@ -215,6 +219,7 @@ def robosign_images(args, s3, build, gpgkey): request_type='artifacts-sign', config=args.fedmsg_conf, request_timeout=ROBOSIGNATORY_REQUEST_TIMEOUT_SEC, + priority=ROBOSIGNATORY_MESSAGE_PRIORITY, environment=fedenv, body={ 'build_id': args.build, diff --git a/src/cosalib/fedora_messaging_request.py b/src/cosalib/fedora_messaging_request.py index 803842780d..9ff9741e78 100644 --- a/src/cosalib/fedora_messaging_request.py +++ b/src/cosalib/fedora_messaging_request.py @@ -53,6 +53,7 @@ def send_request_and_wait_for_response(request_type, config=None, environment='prod', request_timeout=DEFAULT_REQUEST_TIMEOUT_SEC, + priority=None, body={}): assert environment in ['prod', 'stg'] assert request_type in ['ostree-sign', 'artifacts-sign', 'ostree-import'] @@ -72,7 +73,8 @@ def send_request_and_wait_for_response(request_type, # Send the message/request send_message(config=config, topic=get_request_topic(request_type, environment), - body={**body, 'request_id': request_id}) + body={**body, 'request_id': request_id}, + priority=priority) # Wait for the response to come back return wait_for_response(cond, request_timeout) @@ -93,7 +95,7 @@ def broadcast_fedmsg(broadcast_type, # Send the message/request send_message(config=config, topic=get_broadcast_topic(broadcast_type, environment), - body=body) + body=body, priority=None) def get_broadcast_topic(broadcast_type, environment): @@ -108,7 +110,7 @@ def get_request_finished_topic(request_type, environment): return get_request_topic(request_type, environment) + '.finished' -def send_message(config, topic, body): +def send_message(config, topic, body, priority): print(f"Sending {topic} with body {body}") # This is a bit hacky; we fork to publish the message here so that we can # load the publishing fedora-messaging config. The TL;DR is: we need auth @@ -117,17 +119,18 @@ def send_message(config, topic, body): # inherit anything by default (like the Twisted state). ctx = mp.get_context('spawn') p = ctx.Process(target=send_message_impl, - args=(config, topic, body)) + args=(config, topic, body, priority)) p.start() p.join() -def send_message_impl(config, topic, body): +def send_message_impl(config, topic, body, priority): if config: conf.load_config(config) - publish( - message.Message(body=body, topic=topic) - ) + msg = message.Message(body=body, topic=topic) + if priority: + msg.priority = priority + publish(msg) def wait_for_response(cond, request_timeout):