#941 Make wait-for-signed-ostree repeat the fedmsg in case the signer crashed
Merged 6 years ago by lsedlar. Opened 6 years ago by puiterwijk.
puiterwijk/pungi repeat-ostree-fedsmg  into  master

@@ -5,6 +5,7 @@ 

  

  import argparse

  import datetime

+ import fedmsg.config

  import json

  import os

  import sys
@@ -29,9 +30,21 @@ 

      commit = data['commitid']

      path = '%s/objects/%s/%s.commitmeta' % (repo, commit[:2], commit[2:])

  

+     config = fedmsg.config.load_config()

+     config['active'] = True           # Connect out to a fedmsg-relay instance

+     config['cert_prefix'] = 'releng'  # Use this cert.

+     fedmsg.init(**config)

+     topic = 'compose.%s' % opts.cmd.replace('-', '.').lower()

+ 

+     count = 0

      while not os.path.exists(path):

          print('%s: Commit not signed yet, waiting...'

                % datetime.datetime.utcnow())

+         count += 1

+         if count >= 60:  # Repeat every 5 minutes

+             print('Repeating notification')

+             fedmsg.publish(topic=topic, modname='pungi', msg=data)

+             count = 0

          time.sleep(5)

  

      print('Found signature.')

Generally looks fine to me (there is some code duplication with pungi-fedmsg-notification script, but that's fine for now).
Do you think there should be some indication that the same message is resent again?

Codewise it looks OK. Originally I had doubts about missing import fedmsg.init and fedmsg.publish, but it seems "import fedmsg.config" imports it all.

Let's merge as is :smile:

Pull-Request has been merged by lsedlar

6 years ago

@lsedlar: print('Repeating notification') should indicate it's resent, not?
Or do you want something else?

@puiterwijk I meant adding something to the message itself so that recipients know this is another attempt at sending the same message (they might be seeing the same message for the second time).

I'm not sure if this would be useful for anyone, it was just a thought.