Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd-sign: set priority level on Robosignatory fedmsg #3444

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! (that's the only part where my review might be relevant ;-) )

publish(msg)


def wait_for_response(cond, request_timeout):
Expand Down