Skip to content

Commit

Permalink
Message schemas: set chroot message severity to DEBUG
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <[email protected]>
  • Loading branch information
abompard committed Aug 7, 2024
1 parent 70e86dc commit 49a59a2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions messaging/copr_messaging/private/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def usernames(self):


class _BuildChrootMessage(_BuildMessage):

@property
def chroot(self):
"""
Expand Down
36 changes: 36 additions & 0 deletions messaging/copr_messaging/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,24 @@

import copy

from fedora_messaging import message

from copr_common.enums import StatusEnum

from .private.hierarchy import _BuildChrootMessage, _CoprMessage
from .private.schema_old import _PreFMBuildMessage
from .private import schema_stomp_old


_build_ended_template = """Package: {name}-{version}-{release}
Status: {status}
Built by: {owner_name}
ID: {id}
Started: {started}
Finished: {finished}
"""

class BuildChrootEnded(_BuildChrootMessage):
"""
Representation of a message sent by Copr build system right after some Copr
Expand All @@ -47,6 +58,25 @@ def summary(self):
self.status,
)

def __str__(self):
_build_str = _build_template.format(
name=self.name,
version=self.version,
release=self.release,
status=self.new_state_name,
owner_name=self.owner,
id=self.build_id,
started=date_to_string(self.body["creation_time"]),
finished=date_to_string(self.body["completion_time"]) or "(still running)",
)
if self.body["task"] is None:
_task_str = "Build imported into koji\n"
else:
_task_str = "Closed tasks:\n-------------\n"
_task_str += fill_task_template(self.body["task"], self.body["files_base_url"])

return _build_str + _task_str

@property
def agent_name(self):
"""The username who caused the action that generated this message."""
Expand Down Expand Up @@ -100,6 +130,12 @@ class BuildChrootStartedV1DontUse(_PreFMBuildMessage, BuildChrootStarted):
"""
topic = 'copr.chroot.start'

# Set the chroot message severity to DEBUG, which will not generate a notification in FMN by
# default. Those are always paired with a build message, so it makes more sense to notify on
# that one.
# Ref: https://fedora-messaging.readthedocs.io/en/stable/user-guide/messages.html#useful-accessors
severity = message.DEBUG


class BuildChrootStartedV1Stomp(schema_stomp_old._OldStompChrootMessage,
BuildChrootStarted):
Expand Down

0 comments on commit 49a59a2

Please sign in to comment.