Fix multipath device search
When nailgun-agent starts before device mapper assembles multipath devices it reports physical disks that are used for multipath devices as usual disks. This patch does the following * filter out devices that are DM_MULTIPATH_DEVICE_PATH = 1 * run 'udevadm settle' before scanning multipath devices * delays scanning multipath devices until building block device info Change-Id: I088aede0cf3bd1d16a57e7cdec4e50cab2c19175 Closes-Bug: #1652788
This commit is contained in:
parent
3c23b6307d
commit
8fbc4d6405
28
agent
28
agent
|
@ -167,7 +167,6 @@ class NodeAgent
|
||||||
@facter = facter_system_info
|
@facter = facter_system_info
|
||||||
@network = _network
|
@network = _network
|
||||||
@numa_topology = get_numa_topology
|
@numa_topology = get_numa_topology
|
||||||
@mpath_devices, @skip_devices = multipath_devices
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_scheme_and_port
|
def get_scheme_and_port
|
||||||
|
@ -721,11 +720,13 @@ class NodeAgent
|
||||||
# http://lxr.free-electrons.com/source/drivers/scsi/sd.c?v=4.4#L2340
|
# http://lxr.free-electrons.com/source/drivers/scsi/sd.c?v=4.4#L2340
|
||||||
block_size = 512
|
block_size = 512
|
||||||
|
|
||||||
|
mpath_devices, skip_devices = _multipath_devices
|
||||||
|
|
||||||
(_get_blkdev_info or {} rescue {}).each do |bname, binfo|
|
(_get_blkdev_info or {} rescue {}).each do |bname, binfo|
|
||||||
@logger.debug("Found block device: #{bname}")
|
@logger.debug("Found block device: #{bname}")
|
||||||
@logger.debug("Block device info: #{binfo.inspect}")
|
@logger.debug("Block device info: #{binfo.inspect}")
|
||||||
dname = bname.gsub(/!/, '/')
|
dname = bname.gsub(/!/, '/')
|
||||||
next if @skip_devices.include?(dname)
|
next if skip_devices.include?(dname)
|
||||||
|
|
||||||
if physical_data_storage_devices.map{|d| d[:name]}.include?(bname) && binfo
|
if physical_data_storage_devices.map{|d| d[:name]}.include?(bname) && binfo
|
||||||
@logger.debug("Block device seems to be physical data storage: #{bname}")
|
@logger.debug("Block device seems to be physical data storage: #{bname}")
|
||||||
|
@ -749,8 +750,8 @@ class NodeAgent
|
||||||
:paths => nil
|
:paths => nil
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif @mpath_devices.has_key?(dname)
|
elsif mpath_devices.has_key?(dname)
|
||||||
device = @mpath_devices[dname]
|
device = mpath_devices[dname]
|
||||||
detailed_meta[:disks] << {
|
detailed_meta[:disks] << {
|
||||||
:name => 'mapper/' + device["DM_NAME"],
|
:name => 'mapper/' + device["DM_NAME"],
|
||||||
:model => binfo[:model],
|
:model => binfo[:model],
|
||||||
|
@ -781,8 +782,13 @@ class NodeAgent
|
||||||
[nil, nil]
|
[nil, nil]
|
||||||
end
|
end
|
||||||
|
|
||||||
def multipath_devices
|
def _multipath_devices
|
||||||
dmsetup = `/sbin/dmsetup info -c --nameprefixes --noheadings -o blkdevname,subsystem,blkdevs_used,name,uuid`
|
@logger.debug("Waiting for udev to complete evaluating rules")
|
||||||
|
`udevadm settle`
|
||||||
|
|
||||||
|
dmsetup_command = "/sbin/dmsetup info -c --nameprefixes --noheadings -o blkdevname,subsystem,blkdevs_used,name,uuid"
|
||||||
|
@logger.debug("Running command: #{dmsetup_command}")
|
||||||
|
dmsetup = `#{dmsetup_command}`
|
||||||
# Example output:
|
# Example output:
|
||||||
# DM_BLKDEVNAME='dm-0':DM_SUBSYSTEM='mpath':DM_BLKDEVS_USED='sdb,sda':DM_NAME='31234567890abcdef':DM_UUID='mpath-31234567890abcdef'
|
# DM_BLKDEVNAME='dm-0':DM_SUBSYSTEM='mpath':DM_BLKDEVS_USED='sdb,sda':DM_NAME='31234567890abcdef':DM_UUID='mpath-31234567890abcdef'
|
||||||
# DM_BLKDEVNAME='dm-1':DM_SUBSYSTEM='mpath':DM_BLKDEVS_USED='sdc,sdd':DM_NAME='92344567890abcdef':DM_UUID='mpath-92344567890abcdef'
|
# DM_BLKDEVNAME='dm-1':DM_SUBSYSTEM='mpath':DM_BLKDEVS_USED='sdc,sdd':DM_NAME='92344567890abcdef':DM_UUID='mpath-92344567890abcdef'
|
||||||
|
@ -803,7 +809,10 @@ class NodeAgent
|
||||||
end
|
end
|
||||||
mpath_devices[device["DM_BLKDEVNAME"]] = device
|
mpath_devices[device["DM_BLKDEVNAME"]] = device
|
||||||
end
|
end
|
||||||
|
mapping.uniq!
|
||||||
end
|
end
|
||||||
|
@logger.debug("Multipath devices: #{mpath_devices}")
|
||||||
|
@logger.debug("Physical devices that are used in multipath devices: #{mapping}")
|
||||||
[mpath_devices, mapping]
|
[mpath_devices, mapping]
|
||||||
rescue => e
|
rescue => e
|
||||||
@logger.error("Error '#{e.message}' while scanning for multipath devices.")
|
@logger.error("Error '#{e.message}' while scanning for multipath devices.")
|
||||||
|
@ -987,6 +996,9 @@ class NodeAgent
|
||||||
end
|
end
|
||||||
@logger.debug("Device #{devname} udev properties: #{properties.inspect}")
|
@logger.debug("Device #{devname} udev properties: #{properties.inspect}")
|
||||||
|
|
||||||
|
@logger.debug("Filtering out devices that are used in multipath devices: 'DM_MULTIPATH_DEVICE_PATH' = '1'")
|
||||||
|
next if properties['DM_MULTIPATH_DEVICE_PATH'] == '1'
|
||||||
|
|
||||||
@logger.debug("Trying to find out if device #{devname} is removable or not")
|
@logger.debug("Trying to find out if device #{devname} is removable or not")
|
||||||
if File.exists?("/sys/block/#{basename_dir}/removable")
|
if File.exists?("/sys/block/#{basename_dir}/removable")
|
||||||
removable = File.open("/sys/block/#{basename_dir}/removable"){ |f| f.read_nonblock(1024).strip }
|
removable = File.open("/sys/block/#{basename_dir}/removable"){ |f| f.read_nonblock(1024).strip }
|
||||||
|
@ -994,12 +1006,14 @@ class NodeAgent
|
||||||
@logger.debug("Device #{devname} removable parameter: #{removable.inspect}")
|
@logger.debug("Device #{devname} removable parameter: #{removable.inspect}")
|
||||||
|
|
||||||
if STORAGE_CODES.include?(properties['MAJOR'].to_i)
|
if STORAGE_CODES.include?(properties['MAJOR'].to_i)
|
||||||
@logger.debug("Device #{devname} seems to be appropriate")
|
|
||||||
# Exclude LVM volumes (in CentOS - 253, in Ubuntu - 252) using additional check
|
# Exclude LVM volumes (in CentOS - 253, in Ubuntu - 252) using additional check
|
||||||
# Exclude any storage device connected through USB by the default
|
# Exclude any storage device connected through USB by the default
|
||||||
|
@logger.debug("Trying to exclude LVM volumes and USB devices")
|
||||||
next if properties['DEVPATH'].include?('virtual/block/dm') ||
|
next if properties['DEVPATH'].include?('virtual/block/dm') ||
|
||||||
(properties['ID_BUS'] == 'usb' &&
|
(properties['ID_BUS'] == 'usb' &&
|
||||||
!@settings.has_key?("report_usb_block_devices"))
|
!@settings.has_key?("report_usb_block_devices"))
|
||||||
|
|
||||||
|
@logger.debug("Device #{devname} seems to be appropriate")
|
||||||
@blocks << {
|
@blocks << {
|
||||||
:name => basename_dir,
|
:name => basename_dir,
|
||||||
:disk => _disk_path_by_name(devname) || devname,
|
:disk => _disk_path_by_name(devname) || devname,
|
||||||
|
|
Loading…
Reference in New Issue