Avoid duplicate /bin/lsblk calls in the setup module.

The setup module calls /bin/lsblk once for each device appearing in the /etc/mtab file. However, the same device appears there mutliple times when the system uses bind-mounts. As a result, /bin/lsblk is being called repeatedly to get the uuid of the same device.

On a system with many mounts, this leads to a TimeoutError in the get_mount_facts function of the setup module as described in #14551.

Fixes #14551
pull/14899/head
Marc Pujol 9 years ago committed by James Cammarata
parent 7ca33faee6
commit b399fd64d4

@ -1038,6 +1038,7 @@ class LinuxHardware(Hardware):
@timeout(10) @timeout(10)
def get_mount_facts(self): def get_mount_facts(self):
uuids = dict()
self.facts['mounts'] = [] self.facts['mounts'] = []
mtab = get_file_content('/etc/mtab', '') mtab = get_file_content('/etc/mtab', '')
for line in mtab.split('\n'): for line in mtab.split('\n'):
@ -1053,6 +1054,9 @@ class LinuxHardware(Hardware):
except OSError: except OSError:
continue continue
if fields[0] in uuids:
uuid = uuids[fields[0]]
else:
uuid = 'NA' uuid = 'NA'
lsblkPath = module.get_bin_path("lsblk") lsblkPath = module.get_bin_path("lsblk")
if lsblkPath: if lsblkPath:
@ -1060,6 +1064,7 @@ class LinuxHardware(Hardware):
if rc == 0: if rc == 0:
uuid = out.strip() uuid = out.strip()
uuids[fields[0]] = uuid
self.facts['mounts'].append( self.facts['mounts'].append(
{'mount': fields[1], {'mount': fields[1],

Loading…
Cancel
Save