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 15, 2022
1 parent a2c9e1a commit 30689cc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 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 Down Expand Up @@ -231,6 +232,9 @@ def osbuildImage(name, version, distro, image_type, target, arches, opts=None, p
context.session.assertPerm("image")
args = [name, version, distro, image_type, target, arches, opts]
task = {"channel": "image"}
logger = logging.getLogger('koji.plugins')

logger.info("Create osbuildImage task")

try:
jsonschema.validate(args, OSBUILD_IMAGE_SCHEMA)
Expand All @@ -246,4 +250,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 30689cc

Please sign in to comment.