Skip to content

Commit

Permalink
cmd-sign: set priority level on Robosignatory fedmsg
Browse files Browse the repository at this point in the history
There is work in Fedora infra[[1]] to use a Robosignatory queue that
supports priority levels so that e.g. our artifact signing messages are
handled before RPM signing of mass rebuilds.

Start setting a priority level. Set it to 4 as proposed.[[2]]

[1]: https://pagure.io/fedora-infrastructure/issue/10899
[2]: https://pagure.io/fedora-infrastructure/issue/10899#comment-854645
  • Loading branch information
jlebon committed May 3, 2023
1 parent 44e7b4d commit 6da04c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/cmd-sign
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 11 additions & 8 deletions src/cosalib/fedora_messaging_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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)

Expand All @@ -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):
Expand All @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit 6da04c5

Please sign in to comment.