Skip to content

Commit

Permalink
hub: Log adding tasks to Koji's db
Browse files Browse the repository at this point in the history
Log both the entrypoint and the return value from adding a task to
Koji's database. We can measure both to ensure a task has been
successfully added to the database as a service level indicator.
  • Loading branch information
ochosi committed Nov 16, 2022
1 parent 30dd283 commit 770c068
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion plugins/hub/osbuild.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Koji osbuild integration for Koji Hub"""
import sys
import logging
import jsonschema

import koji
Expand All @@ -9,6 +10,9 @@
import kojihub # pylint: disable=import-error, wrong-import-position


logger = logging.getLogger('koji.plugin.osbuild')


OSBUILD_IMAGE_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "osbuildImage arguments",
Expand Down Expand Up @@ -232,6 +236,8 @@ def osbuildImage(name, version, distro, image_type, target, arches, opts=None, p
args = [name, version, distro, image_type, target, arches, opts]
task = {"channel": "image"}

logger.info("Create osbuildImage task")

try:
jsonschema.validate(args, OSBUILD_IMAGE_SCHEMA)
except jsonschema.exceptions.ValidationError as err:
Expand All @@ -246,4 +252,10 @@ def osbuildImage(name, version, distro, image_type, target, arches, opts=None, p
if priority and priority < 0 and not context.session.hasPerm('admin'):
raise koji.ActionNotAllowed('only admins may create high-priority tasks')

return kojihub.make_task('osbuildImage', args, **task)
# If task_id is returned from Koji Hub we assume
# that the task has been added to the database
task_id = kojihub.make_task('osbuildImage', args, **task)
if task_id:
logger.info("osbuildImage task %i added to database", task_id)

return task_id

0 comments on commit 770c068

Please sign in to comment.