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

k8s execute_module\nAttributeError: 'NoneType' object has no attribute 'endswith'\n" #63652

Closed
ghost opened this issue Oct 17, 2019 · 4 comments · Fixed by ansible-collections/community.kubernetes#180
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. clustering Clustering category collection:community.kubernetes collection Related to Ansible Collections work deprecated This issue/PR relates to a deprecated module. k8s module This issue/PR relates to a module. python3 support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback.

Comments

@ghost
Copy link

ghost commented Oct 17, 2019

SUMMARY

Observing error using k8s module to do validations on k8s objects.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

k8s or k8s_raw

ANSIBLE VERSION
ansible --version
ansible 2.8.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/Users/testu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/2.8.5/libexec/lib/python3.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.4 (default, Sep  7 2019, 18:29:04) [Clang 10.0.0 (clang-1000.11.45.5)]

CONFIGURATION

OS / ENVIRONMENT

I have Mac OS
Darwin 17.7.0 Darwin Kernel Version 17.7.0: Wed Apr 24 21:17:24 PDT 2019; root:xnu-4570.71.45~1/RELEASE_X86_64 x86_64

STEPS TO REPRODUCE
      - name: "Validate k8s version KUBECTL"
        shell: "kubectl version --short"
        register: k8s_version
        failed_when: k8s_version.rc == 1
      - debug:
          var: k8s_version.stdout
      - name: "Validate k8s Versions Client & Server: K8s Module"
        k8s:
          validate:
          verify_ssl: no
EXPECTED RESULTS
ACTUAL RESULTS
TASK [2_k8s_validations : debug] ***********************************************************************************************************************************
ok: [localhost] => {
    "k8s_version.stdout": "Client Version: v1.10.1\nServer Version: v1.13.5"
}

TASK [2_k8s_validations : Validate k8s Versions Client & Server: K8s Module] ***************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "/Users/testu/.ansible/tmp/ansible-tmp-1571351337.4579258-273170310360257/AnsiballZ_k8s.py:18: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses\n  import imp\nTraceback (most recent call last):\n  File \"/Users/testu/.ansible/tmp/ansible-tmp-1571351337.4579258-273170310360257/AnsiballZ_k8s.py\", line 114, in <module>\n    _ansiballz_main()\n  File \"/Users/amohmad/.ansible/tmp/ansible-tmp-1571351337.4579258-273170310360257/AnsiballZ_k8s.py\", line 106, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/Users/testu/.ansible/tmp/ansible-tmp-1571351337.4579258-273170310360257/AnsiballZ_k8s.py\", line 49, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/usr/local/Cellar/ansible/2.8.5/libexec/lib/python3.7/imp.py\", line 234, in load_module\n    return load_source(name, filename, file)\n  File \"/usr/local/Cellar/ansible/2.8.5/libexec/lib/python3.7/imp.py\", line 169, in load_source\n    module = _exec(spec, sys.modules[name])\n  File \"<frozen importlib._bootstrap>\", line 630, in _exec\n  File \"<frozen importlib._bootstrap_external>\", line 728, in exec_module\n  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n  File \"/var/folders/qq/t_5mbv151fxfq9_vdgyvcvg8yz98pj/T/ansible_k8s_payload_yo7cq9fu/__main__.py\", line 258, in <module>\n  File \"/var/folders/qq/t_5mbv151fxfq9_vdgyvcvg8yz98pj/T/ansible_k8s_payload_yo7cq9fu/__main__.py\", line 254, in main\n  File \"/var/folders/qq/t_5mbv151fxfq9_vdgyvcvg8yz98pj/T/ansible_k8s_payload_yo7cq9fu/ansible_k8s_payload.zip/ansible/module_utils/k8s/raw.py\", line 160, in execute_module\nAttributeError: 'NoneType' object has no attribute 'endswith'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP *********************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   


@ansibot
Copy link
Contributor

ansibot commented Oct 17, 2019

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 Oct 17, 2019

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. clustering Clustering category k8s module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. python3 support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback. labels Oct 17, 2019
@willthames
Copy link
Contributor

I'm not sure what you expect to happen when validating a non-existent resource with a badly formed validate parameter.

The problem here is that kind is None, and so doesn't have an endswith object. kind can be supplied in a number of ways (through src, definition and kind itself) so it's difficult to check every single edge case (not saying we shouldn't). While we could improve error handling, this failure is not at all surprising

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Oct 19, 2019
@ansibot
Copy link
Contributor

ansibot commented Mar 27, 2020

Files identified in the description:

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

click here for bot help

@ansibot ansibot added the deprecated This issue/PR relates to a deprecated module. label Mar 27, 2020
@ansibot ansibot added collection Related to Ansible Collections work collection:community.kubernetes labels Apr 29, 2020
Akasurde added a commit to Akasurde/community.kubernetes that referenced this issue Aug 4, 2020
kind can be provided by number of ways. It is diffcult to
find all cases. So, handle exceptions raised by underlying
APIs and provide good error message to user.

Fixes: ansible/ansible#63652

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to ansible-collections/community.kubernetes that referenced this issue Aug 11, 2020
kind can be provided by number of ways. It is diffcult to
find all cases. So, handle exceptions raised by underlying
APIs and provide good error message to user.

Fixes: ansible/ansible#63652

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@ansible ansible locked and limited conversation to collaborators Sep 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. clustering Clustering category collection:community.kubernetes collection Related to Ansible Collections work deprecated This issue/PR relates to a deprecated module. k8s module This issue/PR relates to a module. python3 support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants