Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary /bin/lsblk executions in the get_mount_facts function of the setup module #14551

Closed
kilburn opened this issue Feb 18, 2016 · 0 comments · Fixed by #14552
Closed
Labels
bug This issue/PR relates to a bug.

Comments

@kilburn
Copy link
Contributor

kilburn commented Feb 18, 2016

Issue Type:
  • Bug Report
Ansible Version:
ansible 2.0.0.2
  config file = /Users/kilburn/Documents/Projects/tu/plataforma/ansible.cfg
  configured module search path = Default w/o overrides
ansible 2.1.0 (devel 517acb5773) last updated 2016/02/18 08:46:22 (GMT +200)
  lib/ansible/modules/core: (detached HEAD 8d126bd877) last updated 2016/02/18 08:46:32 (GMT +200)
  lib/ansible/modules/extras: (detached HEAD f6c5ed987f) last updated 2016/02/18 08:46:39 (GMT +200)
  config file = 
  configured module search path = Default w/o overrides
Ansible Configuration:

None relevant.

Environment:

Controller is OS X 10.10.5, the managed OS is Debian Jessie 8.3 (fully updated at the time of this writing).

Summary:

This is probably related to #10779. Function get_mount_facts times out on my test machine, throwing the following error:

test | FAILED! => {
    "changed": false, 
    "cmd": "/bin/lsblk -ln --output UUID /dev/dm-0", 
    "failed": true, 
    "msg": "Traceback (most recent call last):\n  File \"<stdin>\", line 1999, in run_command\n  File \"<stdin>\", line 2156, in _handle_timeout\nTimeoutError: Timer expired\n", 
    "rc": 257
}

The root cause is that, to setup multiple chroots, my test machine has many bind mounted paths. These paths appear in /etc/mtab, for instance:

/dev/dm-0 /srv/user1/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9 ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
/dev/dm-0 /srv/user2/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9 ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
/dev/dm-0 /srv/user3/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9 ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
/dev/dm-0 /srv/user4/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9 ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
/dev/dm-0 /srv/user5/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9 ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
...

In the current implementation, get_mount_facts calls the lsblk binary to get the uuid of each device (first field of a line starting with /, such as those lines above). This means that lsblk is being called here many times to get the uuid of the same /dev/dm-0 device. That many calls make the function end up timing out.

Since the uuid of /dev/dm-0 is always going to be the same, all these calls could be avoided by caching the results of the first lsblk /dev/dm-0 execution.

Steps To Reproduce:

Setup a large number of bind-mounts on a test machine test. Run ansible -m setup test.

Expected Results:

You get the machine's facts.

Actual Results:
test | FAILED! => {
    "changed": false, 
    "cmd": "/bin/lsblk -ln --output UUID /dev/dm-0", 
    "failed": true, 
    "msg": "Traceback (most recent call last):\n  File \"<stdin>\", line 1999, in run_command\n  File \"<stdin>\", line 2156, in _handle_timeout\nTimeoutError: Timer expired\n", 
    "rc": 257
}
@kilburn kilburn changed the title Unnecessary /bin/lsblk executions in the get_mount_facts function of the setup module Unnecessary /bin/lsblk executions in the get_mount_facts function of the setup module Feb 18, 2016
kilburn added a commit to kilburn/ansible that referenced this issue Feb 18, 2016
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 ansible#14551.

Fixes ansible#14551
jimi-c pushed a commit that referenced this issue Feb 25, 2016
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
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants