summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCsaba Henk <csaba@redhat.com>2012-05-22 14:03:32 +0530
committerVijay Bellur <vbellur@redhat.com>2012-10-31 09:46:27 -0400
commite336ccf879605adef133aaefd69d9877c47d96e2 (patch)
treeb3194092c2122babbf9c01ab815e0a995e94bf37
parente9cd619c8d77d8f914661dad61aae4c40fdc1fcf (diff)
geo-rep / gsyncd: sanitize error log of external commands
If a command invoked by gsyncd fails, gsyncd makes a log of what comes out on its stderr. So far the log indeterministically broke lines at random places. Now put some effort into reconstructing original lines and having a faithful log. BUG: 870502 Change-Id: I16fcc75d3e0f624c10c71d9b37c937ca677087cc Signed-off-by: Csaba Henk <csaba@redhat.com> Reviewed-on: https://code.engineering.redhat.com/gerrit/166 Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/features/marker/utils/syncdaemon/resource.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/resource.py b/xlators/features/marker/utils/syncdaemon/resource.py
index 90db1707be9..ae6cf26a6d8 100644
--- a/xlators/features/marker/utils/syncdaemon/resource.py
+++ b/xlators/features/marker/utils/syncdaemon/resource.py
@@ -188,9 +188,17 @@ class Popen(subprocess.Popen):
filling = ", saying:"
logging.error("""command "%s" returned with %s%s""" % \
(" ".join(self.args), repr(self.returncode), filling))
+ lp = ''
+ def logerr(l):
+ logging.error(self.args[0] + "> " + l)
for l in self.elines:
- for ll in l.rstrip().split("\n"):
- logging.error(self.args[0] + "> " + ll.rstrip())
+ ls = l.split('\n')
+ ls[0] = lp + ls[0]
+ lp = ls.pop()
+ for ll in ls:
+ logerr(ll)
+ if lp:
+ logerr(lp)
def errfail(self):
"""fail nicely if child did not terminate with success"""