#76 Drop support for fedmsg and replace by fedora-messaging
Merged 5 years ago by pingou. Opened 5 years ago by cverna.

file modified
+1 -1
@@ -6,7 +6,7 @@ 

  

  EXPOSE 8080

  

- RUN dnf -y install python3-aiohttp python3-werkzeug python3-requests python3-sqlalchemy python3-fedmsg

+ RUN dnf -y install python3-aiohttp python3-werkzeug python3-requests python3-sqlalchemy python3-fedora-messaging

  

  USER 1001

  ENV MDAPI_CONFIG=/etc/mdapi/mdapi.cfg

file removed
-19
@@ -1,19 +0,0 @@ 

- """ This is an example mdapi configuration for fedmsg.

- By convention, it is normally installed as ``/etc/fedmsg.d/mdapi.py``

- 

- For Fedora Infrastructure this file is not needed as we use dynamic

- fedmsg endpoints.

- """

- 

- import socket

- 

- 

- hostname = socket.gethostname().split('.')[0]

- 

- config = dict(

-     endpoints={

-         "mdapi.%s" % hostname: [

-             "tcp://127.0.0.1:3005",

-         ],

-     },

- )

file modified
+21 -16
@@ -44,11 +44,14 @@ 

  import time

  import hashlib

  import xml.etree.ElementTree as ET

+ import sys

+ 

  

- import fedmsg

  import requests

  

  from sqlalchemy import text

+ from fedora_messaging.api import Message, publish

+ from fedora_messaging.exceptions import PublishReturned, ConnectionException

  

  import mdapi.lib as mdapilib

  import mdapi.file_lock as file_lock
@@ -69,11 +72,6 @@ 

  

  padding = 22

  

- fedmsg.init(

-     active=True,

-     cert_prefix='mdapi',

- )

- 

  

  # Some queries to help us sort out what is in the repos

  relations_query = """
@@ -296,11 +294,11 @@ 

  

  

  def publish_changes(name, packages, repomd_url):

-     print('%s Publishing differences to fedmsg:' % (name.ljust(padding)))

+     print('%s Publishing differences to fedora messaging:' % (name.ljust(padding)))

  

      change = bool(packages)

      if not change:

-         print('%s No real changes.  Skipping fedmsg.' % (name.ljust(padding)))

+         print('%s No real changes.  Skipping fedora messaging.' % (name.ljust(padding)))

          return

  

      # Just publish the suffix of the URL.  The prefix is dl.fedoraproject.org
@@ -311,15 +309,22 @@ 

      url = '/'.join(repomd_url.split('/')[4:])

      print("%s   url %s" % (name.ljust(padding), url))

  

-     fedmsg.publish(

-         modname='mdapi',

-         topic='repo.update',

-         msg=dict(

-             name=name,

-             packages=packages,

-             url=url,

+     try:

+         msg = Message(

+             topic="mdapi.repo.update.v1",

+             body=dict(

+                 name=name,

+                 packages=packages,

+                 url=url,

+             )

          )

-     )

+         publish(msg)

+     except PublishReturned as e:

+         print(

+             f"Fedora Messaging broker rejected message {msg.id}: {e}", file=sys.stderr

+         )

+     except ConnectionException as e:

+         print(f"Error sending message {msg.id}: {e}", file=sys.stderr)

  

  

  def install_db(name, src, dest):

file modified
+2 -2
@@ -1,7 +1,7 @@ 

  aiohttp

- fedmsg[all]

+ fedora_messaging

  # this is a requirement of aiohttp but better safe than sorry

- multidict 

+ multidict

  requests

  sqlalchemy

  werkzeug