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

vmware_vm_shell failed when there is VM deleted #732

Closed
keirazhang opened this issue Mar 22, 2021 · 6 comments
Closed

vmware_vm_shell failed when there is VM deleted #732

keirazhang opened this issue Mar 22, 2021 · 6 comments
Assignees
Labels
bug This issue/PR relates to a bug cloud easyfix Good for new comers and easy to start with contribution has_pr module module plugins plugin (any type) python3 traceback
Milestone

Comments

@keirazhang
Copy link

Summary

When I used vmware_vm_shell to execute shell command on a VM, another VM was deleted and caused vmware_vm_shell failed.

ok: [localhost] => {
    "changed": false,
    "failed_when_result": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible-tmp-1616384002.2108204-3887-78505575399347/AnsiballZ_vmware_vm_shell.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/tmp/ansible-tmp-1616384002.2108204-3887-78505575399347/AnsiballZ_vmware_vm_shell.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/tmp/ansible-tmp-1616384002.2108204-3887-78505575399347/AnsiballZ_vmware_vm_shell.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_vm_shell', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib/python3.8/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.8/runpy.py\", line 95, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.8/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_vm_shell.py\", line 364, in <module>\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_vm_shell.py\", line 360, in main\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_vm_shell.py\", line 235, in __init__\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py\", line 222, in find_vm_by_id\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py\", line 241, in find_vm_by_name\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py\", line 138, in find_object_by_name\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/VmomiSupport.py\", line 700, in __call__\n    return self.f(*args, **kwargs)\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/VmomiSupport.py\", line 520, in _InvokeAccessor\n    return self._stub.InvokeAccessor(self, info)\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/StubAdapterAccessorImpl.py\", line 41, in InvokeAccessor\n    result = self._pc.RetrievePropertiesEx(specSet=[filterSpec],\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/VmomiSupport.py\", line 706, in <lambda>\n    self.f(*(self.args + (obj,) + args), **kwargs)\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/VmomiSupport.py\", line 512, in _InvokeMethod\n    return self._stub.InvokeMethod(self, info, args)\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/SoapAdapter.py\", line 1397, in InvokeMethod\n    raise obj # pylint: disable-msg=E0702\npyVmomi.VmomiSupport.ManagedObjectNotFound: (vmodl.fault.ManagedObjectNotFound) {\n   dynamicType = <unset>,\n   dynamicProperty = (vmodl.DynamicProperty) [],\n   msg = \"The object 'vim.VirtualMachine:vm-2047' has already been deleted or has not been completely created\",\n   faultCause = <unset>,\n   faultMessage = (vmodl.LocalizableMessage) [],\n   obj = 'vim.VirtualMachine:vm-2047'\n}\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Issue Type

Bug Report

Component Name

vmware_vm_shell

Ansible Version

ansible 2.10.4
  config file = /home/qiz/workspace/gitlab/newgos_testing/ansible.cfg
  configured module search path = ['/home/qiz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]

Configuration

ANSIBLE_SSH_RETRIES(/home/qiz/workspace/gitlab/newgos_testing/ansible.cfg) = 5
DEFAULT_CALLBACK_PLUGIN_PATH(/home/qiz/workspace/gitlab/newgos_testing/ansible.cfg) = ['/home/qiz/workspace/gitlab/newgos_testing/plugin']
DEFAULT_CALLBACK_WHITELIST(/home/qiz/workspace/gitlab/newgos_testing/ansible.cfg) = ['timer']
DISPLAY_SKIPPED_HOSTS(/home/qiz/workspace/gitlab/newgos_testing/ansible.cfg) = False
RETRY_FILES_ENABLED(/home/qiz/workspace/gitlab/newgos_testing/ansible.cfg) = False

OS / Environment

Oracle Linux 8.3

Steps to Reproduce

  1. Run vmware_vm_shell on a VM to execute some shell command
  2. Delete another VM in the same datacenter at the same time.

Expected Results

vmware_vm_shell be executed successfully. And the vmodl.fault.ManagedObjectNotFound exception should be caught and ignored.

Actual Results

The vmodl.fault.ManagedObjectNotFound exception failed vmware_vm_shell task:

ok: [localhost] => {
    "changed": false,
    "failed_when_result": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible-tmp-1616384002.2108204-3887-78505575399347/AnsiballZ_vmware_vm_shell.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/tmp/ansible-tmp-1616384002.2108204-3887-78505575399347/AnsiballZ_vmware_vm_shell.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/tmp/ansible-tmp-1616384002.2108204-3887-78505575399347/AnsiballZ_vmware_vm_shell.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_vm_shell', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib/python3.8/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.8/runpy.py\", line 95, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.8/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_vm_shell.py\", line 364, in <module>\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_vm_shell.py\", line 360, in main\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_vm_shell.py\", line 235, in __init__\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py\", line 222, in find_vm_by_id\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py\", line 241, in find_vm_by_name\n  File \"/tmp/ansible_vmware_vm_shell_payload_xmlnwzyz/ansible_vmware_vm_shell_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py\", line 138, in find_object_by_name\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/VmomiSupport.py\", line 700, in __call__\n    return self.f(*args, **kwargs)\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/VmomiSupport.py\", line 520, in _InvokeAccessor\n    return self._stub.InvokeAccessor(self, info)\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/StubAdapterAccessorImpl.py\", line 41, in InvokeAccessor\n    result = self._pc.RetrievePropertiesEx(specSet=[filterSpec],\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/VmomiSupport.py\", line 706, in <lambda>\n    self.f(*(self.args + (obj,) + args), **kwargs)\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/VmomiSupport.py\", line 512, in _InvokeMethod\n    return self._stub.InvokeMethod(self, info, args)\n  File \"/usr/local/lib/python3.8/dist-packages/pyVmomi/SoapAdapter.py\", line 1397, in InvokeMethod\n    raise obj # pylint: disable-msg=E0702\npyVmomi.VmomiSupport.ManagedObjectNotFound: (vmodl.fault.ManagedObjectNotFound) {\n   dynamicType = <unset>,\n   dynamicProperty = (vmodl.DynamicProperty) [],\n   msg = \"The object 'vim.VirtualMachine:vm-2047' has already been deleted or has not been completely created\",\n   faultCause = <unset>,\n   faultMessage = (vmodl.LocalizableMessage) [],\n   obj = 'vim.VirtualMachine:vm-2047'\n}\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug cloud module module needs_triage Needs a first human triage before being processed. plugins plugin (any type) python3 traceback labels Mar 22, 2021
@Akasurde
Copy link
Member

@keirazhang Thanks for reporting this issue.

@abikouo Would you be able to tackle this issue? You might want to handle the exception something similar to

except vmodl.fault.ManagedObjectNotFound as not_found:

Let me know if you need some help.

@Akasurde Akasurde added easyfix Good for new comers and easy to start with contribution and removed needs_triage Needs a first human triage before being processed. labels Mar 22, 2021
@Akasurde Akasurde added this to the v1.9.0 milestone Mar 22, 2021
@abikouo abikouo added the WIP Work in progress label Mar 22, 2021
@abikouo abikouo removed the WIP Work in progress label Apr 2, 2021
@abikouo
Copy link
Contributor

abikouo commented Apr 2, 2021

@keirazhang could you please try once again with the PR linked?

@Akasurde Akasurde modified the milestones: v1.9.0, v1.10.0 Apr 5, 2021
@Akasurde
Copy link
Member

Akasurde commented Apr 5, 2021

resolved_by_pr #768

@Akasurde
Copy link
Member

Closing as PR is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug cloud easyfix Good for new comers and easy to start with contribution has_pr module module plugins plugin (any type) python3 traceback
Projects
None yet
Development

No branches or pull requests

4 participants