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

[BUG]: deleted all in NTP is crashing with error #205

Closed
kannankvs opened this issue Mar 31, 2023 · 1 comment
Closed

[BUG]: deleted all in NTP is crashing with error #205

kannankvs opened this issue Mar 31, 2023 · 1 comment

Comments

@kannankvs
Copy link
Contributor

kannankvs commented Mar 31, 2023

Bug Description

When NTP is configured and when DELETE ALL is performed, it fails.

Product Name

eSONiC Collections

Component or Module Name

sonic_ntp

DellEMC Enterprise SONiC Ansible Collection Version

2.0

SONiC Software Version

4.0

Configuration

NTP is configured using CLI as follows.

show ntp global

NTP Global Configuration

NTP authenticate: Yes

show ntp server

NTP Servers minpoll maxpoll Prefer Authentication key ID

1.1.1.1 6 10 False

Steps to Reproduce

After configuring, ran the following playbook to delete all NTP config.

  • name: Ansible resource module example for sonic_aaa
    hosts: datacenter
    gather_facts: False
    connection: httpapi
    collections:
    • dellemc.enterprise_sonic
      tasks:
    • name: Delete NTP server configuration
      sonic_ntp:
      state: deleted

Expected Behavior

It should delete all NTP configs.

Actual Behavior

It throws an error as follows.
TASK [Delete NTP server configuration] *****************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'list' object has no attribute 'get'
fatal: [sonic1]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/root/.ansible/tmp/ansible-local-20769koewrw01/ansible-tmp-1680283498.5821176-20773-245238821663001/AnsiballZ_sonic_ntp.py", line 107, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-local-20769koewrw01/ansible-tmp-1680283498.5821176-20773-245238821663001/AnsiballZ_sonic_ntp.py", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/root/.ansible/tmp/ansible-local-20769koewrw01/ansible-tmp-1680283498.5821176-20773-245238821663001/AnsiballZ_sonic_ntp.py", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.dellemc.enterprise_sonic.plugins.modules.sonic_ntp', init_globals=dict(_module_fqn='ansible_collections.dellemc.enterprise_sonic.plugins.modules.sonic_ntp', _modlib_path=modlib_path),\n File "/usr/lib/python3.10/runpy.py", line 224, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File "/usr/lib/python3.10/runpy.py", line 86, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_ntp.py", line 450, in \n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_ntp.py", line 445, in main\n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/config/ntp/ntp.py", line 89, in execute_module\n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/config/ntp/ntp.py", line 123, in set_config\n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/config/ntp/ntp.py", line 139, in set_state\n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/config/ntp/ntp.py", line 314, in preprocess_want\nAttributeError: 'list' object has no attribute 'get'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Logs

TASK [Delete NTP server configuration] *****************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'list' object has no attribute 'get'
fatal: [sonic1]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/root/.ansible/tmp/ansible-local-20769koewrw01/ansible-tmp-1680283498.5821176-20773-245238821663001/AnsiballZ_sonic_ntp.py", line 107, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-local-20769koewrw01/ansible-tmp-1680283498.5821176-20773-245238821663001/AnsiballZ_sonic_ntp.py", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/root/.ansible/tmp/ansible-local-20769koewrw01/ansible-tmp-1680283498.5821176-20773-245238821663001/AnsiballZ_sonic_ntp.py", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.dellemc.enterprise_sonic.plugins.modules.sonic_ntp', init_globals=dict(_module_fqn='ansible_collections.dellemc.enterprise_sonic.plugins.modules.sonic_ntp', _modlib_path=modlib_path),\n File "/usr/lib/python3.10/runpy.py", line 224, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File "/usr/lib/python3.10/runpy.py", line 86, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_ntp.py", line 450, in \n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_ntp.py", line 445, in main\n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/config/ntp/ntp.py", line 89, in execute_module\n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/config/ntp/ntp.py", line 123, in set_config\n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/config/ntp/ntp.py", line 139, in set_state\n File "/tmp/ansible_sonic_ntp_payload_ohj2ff6n/ansible_sonic_ntp_payload.zip/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/config/ntp/ntp.py", line 314, in preprocess_want\nAttributeError: 'list' object has no attribute 'get'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Screenshots

No response

Additional Information

In plugins/module_utils/network/sonic/config/ntp/ntp.py, function preprocess_want is accessing "want" variable even for DELETE_ALL. In case of DELETE_ALL, want will be NULL.

@kannankvs
Copy link
Contributor Author

plugins/module_utils/network/sonic/config/ntp/ntp.py, function preprocess_want
Buggy line: if state == 'deleted':
POSSIBLE SOLUTION: if want and state == 'deleted':

This was referenced Mar 31, 2023
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

No branches or pull requests

2 participants