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
(cherry picked from commit 8fbc4d6405
)
This commit is contained in:
parent
5e7127f9ec
commit
fd0f4664b3
40
agent
40
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
|
||||||
|
@ -746,11 +745,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}")
|
||||||
|
@ -775,8 +776,8 @@ class NodeAgent
|
||||||
:opt_io => get_opt_io.fetch(dname, block_size)
|
:opt_io => get_opt_io.fetch(dname, block_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
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],
|
||||||
|
@ -807,8 +808,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'
|
||||||
|
@ -829,7 +835,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.")
|
||||||
|
@ -1013,6 +1022,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 }
|
||||||
|
@ -1020,18 +1032,20 @@ 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"))
|
||||||
@blocks << {
|
|
||||||
:name => basename_dir,
|
@logger.debug("Device #{devname} seems to be appropriate")
|
||||||
:disk => _disk_path_by_name(devname) || devname,
|
@blocks << {
|
||||||
:extra => _disk_id_by_name(devname) || [],
|
:name => basename_dir,
|
||||||
:removable => removable,
|
:disk => _disk_path_by_name(devname) || devname,
|
||||||
}
|
:extra => _disk_id_by_name(devname) || [],
|
||||||
|
:removable => removable,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@logger.debug("Final list of physical devices is: #{@blocks.inspect}")
|
@logger.debug("Final list of physical devices is: #{@blocks.inspect}")
|
||||||
|
|
Loading…
Reference in New Issue