From cf5a8306e7ac620834efe50f70bb93ed9b2d6fd2 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 5 Nov 2007 15:08:25 +0000 Subject: [PATCH] Fix a unhandled error case in device creation The block device creation process is the following: - device create - device assembly (on primary or depending on dev_type, on secondary too) - set sync speed - return The problem is that device assembly after creation was not checked for errors, and as this is a very unusual case, we did not have problems with it (or we didn't detect them). The recent DevCacheManager however tripped on this case (because the dev_path of the device is None if the assembly fails) and the creation aborted with an unclear error message. The patch adds a check for the assembly success and aborts the creation of the device in this case - the error is quite clear in the instance add, for example. The patch also changes DevCacheManager to log the cases when dev_path is None but not raise an error (keeping consistent with the goal that the cache manager should be transparent to the code). For the record, this error case was detected with a mismatch between drbd kernel module and utilities. Reviewed-by: imsnah --- lib/backend.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/backend.py b/lib/backend.py index 4415223d2..7d92afba2 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -660,7 +660,10 @@ def CreateBlockDevice(disk, size, owner, on_primary, info): raise ValueError("Can't create child device for %s, %s" % (disk, size)) if on_primary or disk.AssembleOnSecondary(): - device.Assemble() + if not device.Assemble(): + raise errors.BlockDeviceError("Can't assemble device after creation," + " very unusual event - check the node" + " daemon logs") device.SetSyncSpeed(constants.SYNC_SPEED) if on_primary or disk.OpenOnSecondary(): device.Open(force=True) @@ -1519,6 +1522,9 @@ class DevCacheManager(object): """Updates the cache information for a given device. """ + if dev_path is None: + logger.Error("DevCacheManager.UpdateCache got a None dev_path") + return fpath = cls._ConvertPath(dev_path) if on_primary: state = "primary" @@ -1538,6 +1544,9 @@ class DevCacheManager(object): """Remove data for a dev_path. """ + if dev_path is None: + logger.Error("DevCacheManager.RemoveCache got a None dev_path") + return fpath = cls._ConvertPath(dev_path) try: utils.RemoveFile(fpath) -- GitLab