Commit 7a380ddf authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Fix a parsing issue with DRBD 8.3.11 in the Linux Kernel



In the Linux kernel commit 4b0715f096 introduced a display bug into
/proc/drbd which broke our regex.

The bug was first introduced into Linux 2.6.39-rc1. This bug is still
unfixed as of today.

This patch adapt the regular expression to workaround this bug for the
time being.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent de5f8826
......@@ -455,6 +455,8 @@ TEST_FILES = \
test/data/proc_drbd8.txt \
test/data/proc_drbd80-emptyline.txt \
test/data/proc_drbd83.txt \
test/data/proc_drbd83_sync.txt \
test/data/proc_drbd83_sync_krnl2.6.39.txt \
test/data/sys_drbd_usermode_helper.txt \
test/import-export_unittest-helper
......
......@@ -785,7 +785,10 @@ class DRBD8Status(object):
LINE_RE = re.compile(r"\s*[0-9]+:\s*cs:(\S+)\s+(?:st|ro):([^/]+)/(\S+)"
"\s+ds:([^/]+)/(\S+)\s+.*$")
SYNC_RE = re.compile(r"^.*\ssync'ed:\s*([0-9.]+)%.*"
"\sfinish: ([0-9]+):([0-9]+):([0-9]+)\s.*$")
# Due to a bug in drbd in the kernel, introduced in
# commit 4b0715f096 (still unfixed as of 2011-08-22)
"(?:\s|M)"
"finish: ([0-9]+):([0-9]+):([0-9]+)\s.*$")
CS_UNCONFIGURED = "Unconfigured"
CS_STANDALONE = "StandAlone"
......
......@@ -166,12 +166,21 @@ class TestDRBD8Status(testutils.GanetiTestCase):
proc_data = self._TestDataFilename("proc_drbd8.txt")
proc80e_data = self._TestDataFilename("proc_drbd80-emptyline.txt")
proc83_data = self._TestDataFilename("proc_drbd83.txt")
proc83_sync_data = self._TestDataFilename("proc_drbd83_sync.txt")
proc83_sync_krnl_data = \
self._TestDataFilename("proc_drbd83_sync_krnl2.6.39.txt")
self.proc_data = bdev.DRBD8._GetProcData(filename=proc_data)
self.proc80e_data = bdev.DRBD8._GetProcData(filename=proc80e_data)
self.proc83_data = bdev.DRBD8._GetProcData(filename=proc83_data)
self.proc83_sync_data = bdev.DRBD8._GetProcData(filename=proc83_sync_data)
self.proc83_sync_krnl_data = \
bdev.DRBD8._GetProcData(filename=proc83_sync_krnl_data)
self.mass_data = bdev.DRBD8._MassageProcData(self.proc_data)
self.mass80e_data = bdev.DRBD8._MassageProcData(self.proc80e_data)
self.mass83_data = bdev.DRBD8._MassageProcData(self.proc83_data)
self.mass83_sync_data = bdev.DRBD8._MassageProcData(self.proc83_sync_data)
self.mass83_sync_krnl_data = \
bdev.DRBD8._MassageProcData(self.proc83_sync_krnl_data)
def testIOErrors(self):
"""Test handling of errors while reading the proc file."""
......@@ -251,5 +260,15 @@ class TestDRBD8Status(testutils.GanetiTestCase):
stats.rrole == 'Unknown' and
stats.is_disk_uptodate)
def testDRBD83SyncFine(self):
stats = bdev.DRBD8Status(self.mass83_sync_data[3])
self.failUnless(stats.is_in_resync)
self.failUnless(stats.sync_percent is not None)
def testDRBD83SyncBroken(self):
stats = bdev.DRBD8Status(self.mass83_sync_krnl_data[3])
self.failUnless(stats.is_in_resync)
self.failUnless(stats.sync_percent is not None)
if __name__ == '__main__':
testutils.GanetiTestProgram()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment