Fix volatile CPU 'size'
The 'size' parameter for CPU returned by lshw is current CPU clock
which changes constantly breaking nailgun optimization which expects
hw data to not change each time.
This also must reduce probability of deadlocks in #1624230.
Change-Id: I7d9b5282991b17424d458c2612dfa4eeeb52be48
Partial-Bug: #1624230
(cherry picked from commit 5e7127f9ec
)
This commit is contained in:
parent
26a7eb39a5
commit
026399208d
19
agent
19
agent
|
@ -1228,6 +1228,23 @@ class NodeAgent
|
|||
res
|
||||
end
|
||||
|
||||
def traverse(item, &block)
|
||||
yield item
|
||||
if item.is_a?(Hash)
|
||||
item.each { |k,v| traverse(v, &block) }
|
||||
elsif item.is_a?(Array)
|
||||
item.each { |elem| traverse(elem, &block) }
|
||||
end
|
||||
end
|
||||
|
||||
#todo: move all quirks here
|
||||
def fixup(data)
|
||||
traverse(data) do |item|
|
||||
# size for CPU means current clock frequency which constantly changes
|
||||
item.delete(:size) if item.is_a?(Hash) and item.fetch(:class, nil) == 'processor'
|
||||
end
|
||||
end
|
||||
|
||||
def _get_pci_dev_list
|
||||
return {} if `cat /etc/nailgun_systemtype`.chomp != 'bootstrap'
|
||||
lshw_timeout = @settings['lshw_timeout'] || 60
|
||||
|
@ -1235,7 +1252,7 @@ class NodeAgent
|
|||
lshw_path = `which lshw`.chomp
|
||||
if $?.success?
|
||||
data = `#{lshw_path} -json -sanitize`
|
||||
return JSON.parse(data) if $?.success?
|
||||
return fixup(JSON.parse(data)) if $?.success?
|
||||
@logger.warn("Can't get data from lshw. Reason: lshw exited with status #{$?.exitstatus}")
|
||||
else
|
||||
@logger.warn("Can't find lshw. Reason: 'which lshw' returned exit status #{$?.exitstatus}")
|
||||
|
|
Loading…
Reference in New Issue