Commit cf5a8306 authored by Iustin Pop's avatar Iustin Pop
Browse files

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
  - 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
parent 65fe4693
......@@ -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():
if not device.Assemble():
raise errors.BlockDeviceError("Can't assemble device after creation,"
" very unusual event - check the node"
" daemon logs")
if on_primary or disk.OpenOnSecondary():
......@@ -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")
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")
fpath = cls._ConvertPath(dev_path)
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