[fedmsg] Patch two issues that bit us overnight.

Ralph Bean ralph at fedoraproject.org
Thu Jul 24 16:21:19 UTC 2014


commit 6c6b6c09c5fe9911ac2bb4cf100e33e6d40cee3e
Author: Ralph Bean <rbean at redhat.com>
Date:   Thu Jul 24 12:20:49 2014 -0400

    Patch two issues that bit us overnight.

 fedmsg-encoding.patch |   34 ++++++++++++++++++++++++++++++
 fedmsg-lock.patch     |   55 +++++++++++++++++++++++++++++++++++++++++++++++++
 fedmsg.spec           |    9 +++++++-
 3 files changed, 97 insertions(+), 1 deletions(-)
---
diff --git a/fedmsg-encoding.patch b/fedmsg-encoding.patch
new file mode 100644
index 0000000..0c07bdb
--- /dev/null
+++ b/fedmsg-encoding.patch
@@ -0,0 +1,34 @@
+From 78942e0063dfe42135ad96ffab5eedf2447dfde5 Mon Sep 17 00:00:00 2001
+From: Ralph Bean <rbean at redhat.com>
+Date: Thu, 24 Jul 2014 12:18:29 -0400
+Subject: [PATCH 2/2] Use fedmsg.encoding here so we can encode
+ moksha.hub.zeromq.ZMQMessage objects.
+
+---
+ fedmsg/consumers/__init__.py | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/fedmsg/consumers/__init__.py b/fedmsg/consumers/__init__.py
+index 3e9edcd..a1b92b5 100644
+--- a/fedmsg/consumers/__init__.py
++++ b/fedmsg/consumers/__init__.py
+@@ -30,6 +30,7 @@ import time
+ import moksha.hub.api.consumer
+ 
+ import fedmsg.crypto
++import fedmsg.encoding
+ from fedmsg.replay import check_for_replay
+ 
+ 
+@@ -248,7 +249,7 @@ class FedmsgConsumer(moksha.hub.api.consumer.Consumer):
+         if self.status_filename:
+             with self.status_lock:
+                 with open(self.status_filename, 'w') as f:
+-                    f.write(json.dumps(data))
++                    f.write(fedmsg.encoding.dumps(data))
+ 
+ 
+ def current_proc():
+-- 
+1.9.3
+
diff --git a/fedmsg-lock.patch b/fedmsg-lock.patch
new file mode 100644
index 0000000..b01e538
--- /dev/null
+++ b/fedmsg-lock.patch
@@ -0,0 +1,55 @@
+From b50eb9a3785c09378405981aca552287b2a076c1 Mon Sep 17 00:00:00 2001
+From: Ralph Bean <rbean at redhat.com>
+Date: Wed, 23 Jul 2014 16:56:02 -0400
+Subject: [PATCH 1/2] Keep status on lock.
+
+Every now and then in production, our status file is corrupted.  I have
+a *hunch* that this is due to multiple threads of a single fedmsg-hub
+trying to write their status at the same time.
+
+This locking should ensure that only one at a time gets to do it.
+---
+ fedmsg/consumers/__init__.py | 12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/fedmsg/consumers/__init__.py b/fedmsg/consumers/__init__.py
+index d4d8447..3e9edcd 100644
+--- a/fedmsg/consumers/__init__.py
++++ b/fedmsg/consumers/__init__.py
+@@ -24,6 +24,7 @@ import logging
+ import os
+ import psutil
+ import requests
++import threading
+ import time
+ 
+ import moksha.hub.api.consumer
+@@ -131,9 +132,11 @@ class FedmsgConsumer(moksha.hub.api.consumer.Consumer):
+             # a thread to set up our workload.
+             self.log.info("Backlog handling setup.  status: %r, url: %r" % (
+                 self.status_filename, self.datagrepper_url))
++            self.status_lock = threading.Lock()
+             try:
+-                with open(self.status_filename, 'r') as f:
+-                    data = f.read()
++                with self.status_lock:
++                    with open(self.status_filename, 'r') as f:
++                        data = f.read()
+                 moksha.hub.reactor.reactor.callInThread(self._backlog, data)
+             except IOError as e:
+                 self.log.info(e)
+@@ -243,8 +246,9 @@ class FedmsgConsumer(moksha.hub.api.consumer.Consumer):
+ 
+     def save_status(self, data):
+         if self.status_filename:
+-            with open(self.status_filename, 'w') as f:
+-                f.write(json.dumps(data))
++            with self.status_lock:
++                with open(self.status_filename, 'w') as f:
++                    f.write(json.dumps(data))
+ 
+ 
+ def current_proc():
+-- 
+1.9.3
+
diff --git a/fedmsg.spec b/fedmsg.spec
index a4445fc..fd1927d 100644
--- a/fedmsg.spec
+++ b/fedmsg.spec
@@ -5,12 +5,14 @@
 
 Name:           fedmsg
 Version:        0.9.1
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Tools for Fedora Infrastructure real-time messaging
 Group:          Applications/Internet
 License:        LGPLv2+
 URL:            http://github.com/ralphbean/fedmsg
 Source0:        http://pypi.python.org/packages/source/f/%{modname}/%{modname}-%{version}.tar.gz
+Patch0:         fedmsg-lock.patch
+Patch1:         fedmsg-encoding.patch
 
 BuildArch:      noarch
 
@@ -122,6 +124,8 @@ socket.  Useful for repeating messages outside a firewall.
 
 %prep
 %setup -q -n %{modname}-%{version}
+%patch0 -p1
+%patch1 -p1
 
 # This only got shipped with fedmsg-0.6.3
 rm -f fedmsg.d/_tweet-real.py
@@ -293,6 +297,9 @@ fi
 %config(noreplace) %{_sysconfdir}/fedmsg.d/gateway.py*
 
 %changelog
+* Thu Jul 24 2014 Ralph Bean <rbean at redhat.com> - 0.9.1-2
+- Bring in two patches from upstream to fix issues on el7.
+
 * Fri Jul 18 2014 Ralph Bean <rbean at redhat.com> - 0.9.1-1
 - Upstream releases with fixes for el6.
 


More information about the scm-commits mailing list