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

[BUG] Linux, LinuxBridge and runtime plugins hangs when retrieving IP address of an FDU interface #136

Closed
gabrik opened this issue Jul 24, 2019 · 1 comment · Fixed by #137
Labels
bug Something isn't working

Comments

@gabrik
Copy link
Contributor

gabrik commented Jul 24, 2019

Describe the bug
The monitoring process of an FDU hangs when it tries to retrieve information from the DHCP about the IP Address of an FDU's interface

To Reproduce
Instantiate an FDU connected to a virtual network, with DHCP

Expected behavior
Should not hang

Desktop (please complete the following information):

  • OS: Ubuntu
  • Version 18.04, 16.04
  • Involved pluging: Linux, LinuxBridge, any runtime plugin

Additional context
Seems that the LinuxPlugin hangs when trying to read data from the dnsmasq lease file, and so all the chain just hangs
Linux plugin output:

[2019-07-24 09:45:27,656] - [INFO] > < read_file() > Arguments: {'root': 'True', 'file_path': '/var/fos/linuxbridge/dhcp/net_6cc2aa30_leases', 'self': <__main__.Linux object at 0x7fa2ef274e48>}

LinuxBridge plugin:

[2019-07-24 09:45:27,655] - [INFO] > < get_address() > Linux Bridge Plugin - Getting IP address for  be:ef:be:ef:00:01

LXD plugin:

[2019-07-24 09:45:27,634] - [INFO] > < __monitor_instance() > [ INFO ] LXD Plugin - Updating status of 9c507cba-ba02-4b89-9abe-b23c2763a294 - c9c507cba-ba02-4b89-9abe-b23c2763a294

The LinuxPlugin acutally, as the parameter root is set to True, should execute this command: sudo cat /var/fos/linuxbridge/dhcp/net_6cc2aa30_leases

That should not hang, the code that hangs is:

if root:
                file_path = 'sudo cat {}'.format(file_path)
                process = subprocess.Popen(
                    file_path.split(), stdout=subprocess.PIPE)
                for line in iter(process.stdout.readline, ''):
                    data = data + '{}'.format(line)

That hangs also if executed in python interpreter

$ python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from subprocess import PIPE
>>> import subprocess
>>> cmd  = 'sudo cat  /var/fos/linuxbridge/dhcp/net_6cc2aa30_leases'
>>> p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
>>> data = ''
>>> for line in iter(p.stdout.readline, ''):
...     data = data + '{}'.format(line)
...

This suggest that we should find another way to read that file

@gabrik gabrik added the bug Something isn't working label Jul 24, 2019
@gabrik
Copy link
Contributor Author

gabrik commented Jul 24, 2019

Quick update, seems that using psutil instead of subprocess solves the issue:

$ python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> from subprocess import PIPE
>>> cmd  = 'sudo cat  /var/fos/linuxbridge/dhcp/net_6cc2aa30_leases'.split()
>>> p = psutil.Popen(cmd,stdout=PIPE)
>>> p.wait()
0
>>> r = ''
>>> for line in p.stdout:
...     r = r + line.decode()
...
>>> r
'1564040719 be:ef:be:ef:00:01 192.168.234.10 c9c507cba-ba02-4b89-9abe-b23c2763a294 01:be:ef:be:ef:00:01\n'
>>>

Also using direct python access to file solves the issue:

f = '/var/fos/linuxbridge/dhcp/net_6cc2aa30_leases'
>>> data = ''
>>> with open(f, 'r') as f:
...     data = f.read()
...
>>> data
'1564041966 be:ef:be:ef:00:01 192.168.234.10 cf009de5b-e6b5-43db-b400-985ad70f4407 01:be:ef:be:ef:00:01\n'

So we will use psutil instead of subprocess in case of root == True

gabrik added a commit to atolab/fog05 that referenced this issue Jul 24, 2019
…rder to solve eclipse-fog05#136

Signed-off-by: gabrik <gabriele.baldoni@gmail.com>
@gabrik gabrik mentioned this issue Jul 24, 2019
6 tasks
gabrik added a commit that referenced this issue Jul 31, 2019
* Added storage descriptors in the IM, updated CP and VirtualLink to follow ETSI specifications
* Added ATD file for atomic entity, using new CP descriptor in FDU
* updated IM, using fog05-im modules for python APIs, code reorganization, cleanup, masking the calls to eval in order to make the code easy to read, new classes for FDU differentiated between users and infrastructure, LXD plugin uses new InfraFDU object for managing FDUs
* Updates and Fixs in Agent, FDU python classes and API
* updates in FDU objects and fixes on linuxbridge and linux plugin in order to solve #136
* updates to KVM and Native Plugin to use the new FDUs objects
* Initial implementation of Atomic Entity onboard and instantiation function on the agent
* updated APIs, Makefile, CLI to follow separation between FIM components and FAEM components

Signed-off-by: gabrik <gabriele.baldoni@gmail.com>
gabrik added a commit that referenced this issue Nov 26, 2020
* Added storage descriptors in the IM, updated CP and VirtualLink to follow ETSI specifications
* Added ATD file for atomic entity, using new CP descriptor in FDU
* updated IM, using fog05-im modules for python APIs, code reorganization, cleanup, masking the calls to eval in order to make the code easy to read, new classes for FDU differentiated between users and infrastructure, LXD plugin uses new InfraFDU object for managing FDUs
* Updates and Fixs in Agent, FDU python classes and API
* updates in FDU objects and fixes on linuxbridge and linux plugin in order to solve #136
* updates to KVM and Native Plugin to use the new FDUs objects
* Initial implementation of Atomic Entity onboard and instantiation function on the agent
* updated APIs, Makefile, CLI to follow separation between FIM components and FAEM components

Signed-off-by: gabrik <gabriele.baldoni@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant