Revision fdbd668d lib/cmdlib.py

b/lib/cmdlib.py
1860 1860
  """
1861 1861
  device_info = []
1862 1862
  disks_ok = True
1863
  iname = instance.name
1864
  # With the two passes mechanism we try to reduce the window of
1865
  # opportunity for the race condition of switching DRBD to primary
1866
  # before handshaking occured, but we do not eliminate it
1867

  
1868
  # The proper fix would be to wait (with some limits) until the
1869
  # connection has been made and drbd transitions from WFConnection
1870
  # into any other network-connected state (Connected, SyncTarget,
1871
  # SyncSource, etc.)
1872

  
1873
  # 1st pass, assemble on all nodes in secondary mode
1863 1874
  for inst_disk in instance.disks:
1864
    master_result = None
1865 1875
    for node, node_disk in inst_disk.ComputeNodeTree(instance.primary_node):
1866 1876
      cfg.SetDiskID(node_disk, node)
1867
      is_primary = node == instance.primary_node
1868
      result = rpc.call_blockdev_assemble(node, node_disk,
1869
                                          instance.name, is_primary)
1877
      result = rpc.call_blockdev_assemble(node, node_disk, iname, False)
1870 1878
      if not result:
1871 1879
        logger.Error("could not prepare block device %s on node %s"
1872
                     " (is_primary=%s)" %
1873
                     (inst_disk.iv_name, node, is_primary))
1874
        if is_primary or not ignore_secondaries:
1880
                     " (is_primary=False, pass=1)" % (inst_disk.iv_name, node))
1881
        if not ignore_secondaries:
1875 1882
          disks_ok = False
1876
      if is_primary:
1877
        master_result = result
1878
    device_info.append((instance.primary_node, inst_disk.iv_name,
1879
                        master_result))
1883

  
1884
  # FIXME: race condition on drbd migration to primary
1885

  
1886
  # 2nd pass, do only the primary node
1887
  for inst_disk in instance.disks:
1888
    for node, node_disk in inst_disk.ComputeNodeTree(instance.primary_node):
1889
      if node != instance.primary_node:
1890
        continue
1891
      cfg.SetDiskID(node_disk, node)
1892
      result = rpc.call_blockdev_assemble(node, node_disk, iname, True)
1893
      if not result:
1894
        logger.Error("could not prepare block device %s on node %s"
1895
                     " (is_primary=True, pass=2)" % (inst_disk.iv_name, node))
1896
        disks_ok = False
1897
    device_info.append((instance.primary_node, inst_disk.iv_name, result))
1880 1898

  
1881 1899
  # leave the disks configured for the primary node
1882 1900
  # this is a workaround that would be fixed better by

Also available in: Unified diff