#591 Handle possible problems with message validation in fedmsg
Merged 3 years ago by lholecek. Opened 3 years ago by lholecek.
lholecek/greenwave message-validation  into  master

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

          msg = {'message': ('Greenwave could not find a parent policy(ies) for following decision'

                             ' context(s): {}. Please change your policy so that it will match a '

                             'decision context in the parent policies.'.format(

-                                ', '.join(missing_decision_contexts)))}

+                                ', '.join(sorted(missing_decision_contexts))))}

      else:

          msg = {'message': 'All OK'}

  

@@ -88,6 +88,20 @@ 

          self.greenwave_api_url = self.flask_app.config['GREENWAVE_API_URL']

          log.info('Greenwave handler listening on: %s', self.topic)

  

+     def validate(self, message):

+         """

+         Wraps fedmsg.consumers.FedmsgConsumer.validate() to avoid propagating

+         unexpected exceptions which would cause fedmsg-hub to get stuck (stops

+         processing messages but doesn't quit).

+         """

+         try:

+             return super(Consumer, self).validate(message)

+         except RuntimeWarning:

+             raise

+         except Exception:

+             log.exception('Failed to validate message: %s', message)

+             raise RuntimeWarning('Unexpected exception during message validation')

+ 

      def consume(self, message):

          """

          Process the given message and take action.

JIRA: RHELWF-1650
Signed-off-by: Lukas Holecek hluk@email.cz

Pull-Request has been merged by lholecek

3 years ago