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

virt.full_info fixes #54335

Merged
merged 2 commits into from
Dec 20, 2019
Merged

virt.full_info fixes #54335

merged 2 commits into from
Dec 20, 2019

Conversation

cbosdo
Copy link
Contributor

@cbosdo cbosdo commented Aug 28, 2019

What does this PR do?

While running virt.full_info module function, several errors happened:

'ERROR: The VM "<libvirt.virDomain object at 0x7fad04208650>" is not present'

and

    The minion function caused an exception: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/minion.py", line 1673, in _thread_return
    return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
  File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 12, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2411, in full_info
    'vm_info': vm_info()}
  File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2020, in vm_info
    info[domain.name()] = _info(domain)
  File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2004, in _info
    'disks': _get_disks(dom),
  File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 465, in _get_disks
    output = _parse_qemu_img_info(qemu_output)
  File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 287, in _parse_qemu_img_info
    raw_infos = salt.utils.json.loads(info)
  File "/usr/lib/python3.6/site-packages/salt/utils/json.py", line 92, in loads
    return json_module.loads(s, **kwargs)
  File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This PR fixes both of these issues.

What issues does this PR fix or reference?

Previous Behavior

Run virt.full_info on a KVM minion with at least a running VM. You will see the first error. Once fixed you will see the second one.

New Behavior

Run virt.full_info on a KVM minion displays the expected data

Tests written?

Yes, merged some scattered unit tests into a full_info test covering it all.

Commits signed with GPG?

Yes

@cbosdo cbosdo requested a review from a team as a code owner October 30, 2019 15:39
@ghost ghost requested a review from DmitryKuzmenko October 30, 2019 15:39
@cbosdo cbosdo changed the base branch from 2019.2.1 to master October 30, 2019 15:39
@cbosdo
Copy link
Contributor Author

cbosdo commented Oct 30, 2019

Rebased on master

Replace a few tests on parts of the virt.full_info feature by a complete
test of virt.full_info
When getting VM disks informations on a running VM, the following error
occured:

    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python3.6/site-packages/salt/minion.py", line 1673, in _thread_return
        return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
      File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 12, in execute
        return func(*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2411, in full_info
        'vm_info': vm_info()}
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2020, in vm_info
        info[domain.name()] = _info(domain)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2004, in _info
        'disks': _get_disks(dom),
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 465, in _get_disks
        output = _parse_qemu_img_info(qemu_output)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 287, in _parse_qemu_img_info
        raw_infos = salt.utils.json.loads(info)
      File "/usr/lib/python3.6/site-packages/salt/utils/json.py", line 92, in loads
        return json_module.loads(s, **kwargs)
      File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
        return _default_decoder.decode(s)
      File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This is due to the fact that qemu-img can't get infos on a disk that is
already used like by a running VM. Using the qemu-img -U flag gets it
running in all cases.
@dwoz dwoz merged commit d04f97a into saltstack:master Dec 20, 2019
@cbosdo cbosdo deleted the virt-full-info-fix branch December 23, 2019 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants