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

redfish_facts results an Unknown error #49713

Closed
warusadura opened this issue Dec 10, 2018 · 14 comments · Fixed by #50129
Closed

redfish_facts results an Unknown error #49713

warusadura opened this issue Dec 10, 2018 · 14 comments · Fixed by #50129
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. remote_management Working Group: https://docs.ansible.com/ansible/latest/community/communication.html support:community This issue/PR relates to code supported by the Ansible community.

Comments

@warusadura
Copy link
Contributor

SUMMARY

Hello Ansible community!
When executing a simple playbook with redfish_facts module, results Unknown error

fatal: [HOST]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "baseuri": "http://127.0.0.1:8000/",
            "category": [
                "Manager"
            ],
            "command": [
                "all"
            ],
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "username": "foo"
        }
    },
    "msg": "Unknown error"
}

I'm unable to debug/improve my playbook with an error like Unknown error. So, I think it would be great if we could improve this to much more verbose error message.

Thanks :)

ISSUE TYPE
  • Bug Report
COMPONENT NAME

redfish_facts

ANSIBLE VERSION
ansible 2.7.4
python version = 3.7.1 (default, Oct 21 2018, 08:03:53) [GCC 8.2.0]
@ansibot
Copy link
Contributor

ansibot commented Dec 10, 2018

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

@ansibot
Copy link
Contributor

ansibot commented Dec 10, 2018

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. remote_management Working Group: https://docs.ansible.com/ansible/latest/community/communication.html support:community This issue/PR relates to code supported by the Ansible community. labels Dec 10, 2018
@jose-delarosa
Copy link
Contributor

jose-delarosa commented Dec 10, 2018

@dnuka I agree that some of the error messages could be more specific. For now, can you please provide more information about your environment? What out-of-band device is listening at http://127.0.0.1:8000? Did you modify the redfish_facts module so that it would connect using http instead of https? (default is https).

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Dec 10, 2018
@warusadura
Copy link
Contributor Author

warusadura commented Dec 11, 2018

Hi @jose-delarosa. Thank you for the quick response. I'm an intern at the OpenStack Ironic team.

For now, can you please provide more information about your environment? What out-of-band device is listening at http://127.0.0.1:8000?

I have configured to run sushy-emulator on a remote cent-os server. And ran this playbook against it.

Did you modify the redfish_facts module so that it would connect using http instead of https? (default is https).

No. I didn't modify the redfish_facts module.

I'm very much new to IT automation, Redfish and still learning Ansible :) Right now I'm trying to figure out why Ansible is outputting "Unknown error". Also, I'm really interested in contributing to redfish_facts module with generating a more specific error message.

Thanks.

@billdodd
Copy link
Contributor

Hi, @dnuka.

Thanks for opening the issue. The "Unknown error" is coming from the redfish_utils module in the final except block of one of the methods get_request(), post_request(), patch_request(), or delete_request(). A good improvement here would be to output a representation of the Exception received rather than just 'Unknown error'. If you are interested, feel free to submit a PR for a fix like that.

@warusadura
Copy link
Contributor Author

warusadura commented Dec 11, 2018

Hi :) @billdodd Thank you for the response.

I was able to figure out why Ansible is outputting "Unknown error" on my side. I have made a mistake when passing baseuri. Also, I just updated the redfish_facts module to support http @jose-delarosa

Updated playbook
Now I'm getting the following error message,

fatal: [HOST]: FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to HOST closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1544508444.8116581-100042417563386/AnsiballZ_redfish_facts.py\", line 113, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1544508444.8116581-100042417563386/AnsiballZ_redfish_facts.py\", line 105, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/root/.ansible/tmp/ansible-tmp-1544508444.8116581-100042417563386/AnsiballZ_redfish_facts.py\", line 48, in invoke_module\r\n    imp.load_module('__main__', mod, module, MOD_DESC)\r\n  File \"/tmp/ansible_redfish_facts_payload_sIgx0e/__main__.py\", line 268, in <module>\r\n  File \"/tmp/ansible_redfish_facts_payload_sIgx0e/__main__.py\", line 199, in main\r\n  File \"/tmp/ansible_redfish_facts_payload_sIgx0e/ansible_redfish_facts_payload.zip/ansible/module_utils/redfish_utils.py\", line 133, in _find_systems_resource\r\nUnboundLocalError: local variable 'systems_service' referenced before assignment\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Thanks for opening the issue. The "Unknown error" is coming from the redfish_utils module in the final except block of one of the methods get_request(), post_request(), patch_request(), or delete_request()

@billdodd Can you please provide me the link to redfish_utils module :)

A good improvement here would be to output a representation of the Exception received rather than just 'Unknown error'. If you are interested, feel free to submit a PR for a fix like that.

Yes! I'm extremely interested.

Thanks.

@billdodd
Copy link
Contributor

The redfish_facts module is here:

https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/redfish_utils.py

For the new error you are seeing, it looks like the Members array in your Systems resource is either empty or missing.

@dtantsur
Copy link
Contributor

I think both errors are bugs. Even if the server is not fully compliant (which I'm not sure), the errors should be better.

@warusadura
Copy link
Contributor Author

Thank you @billdodd :)

For the new error you are seeing, it looks like the Members array in your Systems resource is either empty or missing.

It appears so,

{
    "@odata.type": "#ComputerSystemCollection.ComputerSystemCollection",
    "Name": "Computer System Collection",
    "Members@odata.count": 0,
    "Members": [
        
    ],
    "@odata.context": "/redfish/v1/$metadata#ComputerSystemCollection.ComputerSystemCollection",
    "@odata.id": "/redfish/v1/Systems",
    "@Redfish.Copyright": "Copyright 2014-2016 Distributed Management Task Force, Inc. (DMTF). For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright."
}

I agree with @dtantsur :) We could do better by providing more specific error messages to the end user.

Also, why there are two locations? I mean, lib/ansible/module_utils/ and then /lib/ansible/modules/ I thought only things under lib/ansible/modules were considered valid custom modules. Is this a design choice or is there a specific reason behind it :)

Thanks.

@billdodd
Copy link
Contributor

I completely agree that it is a bug causing the UnboundLocalError when there are no systems. There is another issue related to multiple Systems (#47108). When I fix that issue, the UnboundLocalError will also be fixed.

Regarding the module_utils path, it's part of the Ansible architecture. There is a brief description here: https://docs.ansible.com/ansible/2.7/dev_guide/developing_module_utilities.html

Having much of the core Redfish function in a utility module allows vendors to extend that utility module if they need to develop a module that provides non-standard (OEM) function.

@warusadura
Copy link
Contributor Author

Hi @billdodd

How do I test a modified module. I have found this. But there is no mention of testing against a remote server. Also, I couldn't find any tests for already existing custom redfish modules. Do you have some tests somewhere in some form? As a contributor how do I ensure the workings of the change?

Thanks :)

@billdodd
Copy link
Contributor

Hi @dnuka - The link you referenced describes the environment setup I use for development and testing (at the beginning of the page in the "Environment setup" section). With that venv and hacking/env-setup, when you run a playbook it will use the modules in your local repository.

There aren't any tests (like unit tests or functional tests) for the Redfish ansible modules as far as I know.

But the sample inventory file and playbooks in this repo should be helpful for seeing how to test against a remote Redfish server: https://github.com/dell/redfish-ansible-module

@warusadura
Copy link
Contributor Author

@billdodd Thank you very much for answering all my questions :) It was very helpful. I had some doubts about executing $ . hacking/env-setup. Your answer clears everything.

Please let me know, If there is anything Ansible and Redfish related. I'm very much happy to learn and contribute.
Thanks again :)

@gundalow
Copy link
Contributor

Proposed fix in #50129 (thanks @dnuka) would welcome review on that

@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. remote_management Working Group: https://docs.ansible.com/ansible/latest/community/communication.html support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
6 participants