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

2019.02 virt.vm_info is failing to execute due to _get_domains #52431

Closed
tonyplovich opened this issue Apr 6, 2019 · 6 comments
Closed

2019.02 virt.vm_info is failing to execute due to _get_domains #52431

tonyplovich opened this issue Apr 6, 2019 · 6 comments
Labels
info-needed waiting for more info
Milestone

Comments

@tonyplovich
Copy link

Description of Issue/Question

Looking at 2018.3, vm_info used to iterate through a list of VM names obtained from list_domains. In 2019.02 vm_info now obtains this list from _get_domains which instead returns a list of domain objects. When the domain object is passed into the functions referenced by vm_info._info (_get_uuid, _get_on_crash, _get_on_reboot, and _get_on_poweroff), _get_domain is eventually called again but with a domain object in *vms instead of a vm's name. _get_domain then checks the contents of *vms against the list all_vms, but fails because the domain object (<libvirt.virDomain object at 0x7fddce314a10>) doesn't match any of the vm names.

Setup

virt.vm_info is failing with the following trace:

salt-minion[18311]: [ERROR ] A command in 'virt.vm_info' had a problem: The VM "<libvirt.virDomain object at 0x7fddce314a10>" is not present
salt-minion[18311]: Traceback (most recent call last):
salt-minion[18311]: File "/usr/lib/python2.7/site-packages/salt/minion.py", line 1660, in _thread_return
salt-minion[18311]: return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
salt-minion[18311]: File "/usr/lib/python2.7/site-packages/salt/executors/direct_call.py", line 12, in execute
salt-minion[18311]: return func(*args, **kwargs)
salt-minion[18311]: File "/usr/lib/python2.7/site-packages/salt/modules/virt.py", line 2034, in vm_info
salt-minion[18311]: info[domain.name()] = _info(domain)
salt-minion[18311]: File "/usr/lib/python2.7/site-packages/salt/modules/virt.py", line 2021, in _info
salt-minion[18311]: 'uuid': _get_uuid(dom),
salt-minion[18311]: File "/usr/lib/python2.7/site-packages/salt/modules/virt.py", line 336, in _get_uuid
salt-minion[18311]: return ElementTree.fromstring(get_xml(dom)).find('uuid').text
salt-minion[18311]: File "/usr/lib/python2.7/site-packages/salt/modules/virt.py", line 2452, in get_xml
salt-minion[18311]: xml_desc = get_domain(conn, vm).XMLDesc(0)
salt-minion[18311]: File "/usr/lib/python2.7/site-packages/salt/modules/virt.py", line 273, in _get_domain
salt-minion[18311]: raise CommandExecutionError('The VM "{name}" is not present'.format(name=name))
salt-minion[18311]: CommandExecutionError: The VM "<libvirt.virDomain object at 0x7fddce314a10>" is not present

Steps to Reproduce Issue

Versions Report

salt-master
Salt Version:
Salt: 2019.2.0

Dependency Versions:
cffi: 1.6.0
cherrypy: Not Installed
dateutil: 1.5
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.31.0
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: 2.14
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.5 (default, Oct 30 2018, 23:45:53)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4

System Versions:
dist: centos 7.6.1810 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-957.10.1.el7.x86_64
system: Linux
version: CentOS Linux 7.6.1810 Core

Minion running libvirtd:
Salt Version:
Salt: 2019.2.0

Dependency Versions:
cffi: 1.6.0
cherrypy: Not Installed
dateutil: 1.5
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.31.0
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: 2.14
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.5 (default, Oct 30 2018, 23:45:53)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4

System Versions:
dist: centos 7.6.1810 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-957.10.1.el7.x86_64
system: Linux
version: CentOS Linux 7.6.1810 Core

libvirt packages installed:
rpm -qa | grep -i libvirt
libvirt-libs-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-qemu-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-config-nwfilter-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-storage-disk-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-network-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-interface-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-storage-rbd-4.5.0-10.el7_6.6.x86_64
libvirt-client-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-storage-core-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-secret-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-config-network-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-storage-gluster-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-kvm-4.5.0-10.el7_6.6.x86_64
libvirt-bash-completion-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-nodedev-4.5.0-10.el7_6.6.x86_64
libvirt-python-4.5.0-1.el7.x86_64
libvirt-daemon-driver-lxc-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-storage-iscsi-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-storage-4.5.0-10.el7_6.6.x86_64
libvirt-docs-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-nwfilter-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-storage-mpath-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-storage-logical-4.5.0-10.el7_6.6.x86_64
libvirt-daemon-driver-storage-scsi-4.5.0-10.el7_6.6.x86_64
libvirt-4.5.0-10.el7_6.6.x86_64

@waheedi
Copy link

waheedi commented Apr 7, 2019

Thank you for submitting the issue @tonyplovich

To be able to help answer your question, what command did you use?
was it this:
salt '*' virt.vm_info if yes, can you try to add the domain for a specific vm, salt '*' virt.vm_info Domain-0 if no does this also fail? salt '*' virt.vm_info

I can't see where the _get_domain function is getting a vm object in any case. but the error shows there is a case :)

happy to help

@Ch3LL Ch3LL added the info-needed waiting for more info label Apr 8, 2019
@Ch3LL Ch3LL added this to the Blocked milestone Apr 8, 2019
@tonyplovich
Copy link
Author

I noticed the error when calling vm_info both ways.

I think conn.lookupByName in _get_domain is returning domain objects:

    for name in lookup_vms:
        ret.append(conn.lookupByName(name))

return len(ret) == 1 and not kwargs.get('iterable') and ret[0] or ret

I was able to fix vm_info by updating _info to:

    def _info(dom):
        '''
        Compute the infos of a domain
        '''
        raw = dom.info()
        return {'cpu': raw[3],
                'cputime': int(raw[4]),
                'disks': _get_disks(dom),
                'graphics': _get_graphics(dom),
                'nics': _get_nics(dom),
                'uuid': _get_uuid(dom.name()),
                'on_crash': _get_on_crash(dom.name()),
                'on_reboot': _get_on_reboot(dom.name()),
                'on_poweroff': _get_on_poweroff(dom.name()),
                'maxMem': int(raw[1]),
                'mem': int(raw[2]),
                'state': VIRT_STATE_NAME_MAP.get(raw[0], 'unknown')}

@zer0def
Copy link
Contributor

zer0def commented Apr 16, 2019

@tonyplovich Line numbers in traceback don't align with modules shipped in tag 2019.2.0. Did you happen to install Salt from git?

@tonyplovich
Copy link
Author

tonyplovich commented Apr 17, 2019 via email

@waheedi
Copy link

waheedi commented Apr 17, 2019

@zer0def It was working on your 2019.02 I thought? you are just using a bandaid with this PR, the one I proposed does the real fix and the code were refactored to a better extent.

@gtmanfred now you believe there is a bug in the module for 2019.02 version?

@dsanader
Copy link

How come this hasn't landed in v2019.2.3 ?

This release still contains the buggy code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed waiting for more info
Projects
None yet
Development

No branches or pull requests

5 participants