Open rndmh3ro opened 3 months ago
Attention: Patch coverage is 13.84615%
with 56 lines
in your changes are missing coverage. Please review.
Project coverage is 24.35%. Comparing base (
fff9558
) to head (3d0dea7
). Report is 6 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
SUMMARY
In some cases the error returned by Grafana could have a status code
-1
, e.g.:or
This initial commit fixes the problem for the grafana_user module. However this could happen in all modules. Therefore we should refactor out the send_request function in all modules and fix it there..
test-case:
run grafana
run the following playbook:
< TASK [Create Grafana users] >
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'read' failed: [localhost] (item={'uid': 'username', 'description': 'User Name', 'email': 'user.name@whatever.com', 'password': 'hashed_passwd'}) => {"ansible_loop_var": "member", "changed": false, "member": {"description": "User Name", "email": "user.name@whatever.com", "password": "hashed_passwd", "uid": "username"}, "module_stderr": "Traceback (most recent call last):\n File \"/home/segu/.ansible/tmp/ansible-tmp-1713969893.8799918-1346142-270361372579429/AnsiballZ_grafana_user.py\", line 107, in\n _ansiballz_main()\n File \"/home/segu/.ansible/tmp/ansible-tmp-1713969893.8799918-1346142-270361372579429/AnsiballZ_grafana_user.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/segu/.ansible/tmp/ansible-tmp-1713969893.8799918-1346142-270361372579429/AnsiballZ_grafana_user.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.grafana.plugins.modules.grafana_user', init_globals=dict(_module_fqn='ansible_collections.community.grafana.plugins.modules.grafana_user', _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_community.grafana.grafana_user_payload_ctp3n329/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 323, in \n File \"/tmp/ansible_community.grafana.grafana_user_payload_ctp3n329/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 292, in main\n File \"/tmp/ansible_community.grafana.grafana_user_payload_ctp3n329/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 221, in get_user_from_login\n File \"/tmp/ansible_community.grafana.grafana_user_payload_ctp3n329/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 204, in _send_request\nAttributeError: 'NoneType' object has no attribute 'read'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'read'
failed: [localhost] (item={'uid': 'username2', 'description': 'User Name1', 'email': 'user.name2@whatever.com', 'password': 'hashed_passwd'}) => {"ansible_loop_var": "member", "changed": false, "member": {"description": "User Name1", "email": "user.name2@whatever.com", "password": "hashed_passwd", "uid": "username2"}, "module_stderr": "Traceback (most recent call last):\n File \"/home/segu/.ansible/tmp/ansible-tmp-1713969894.262415-1346142-167829676315139/AnsiballZ_grafana_user.py\", line 107, in \n _ansiballz_main()\n File \"/home/segu/.ansible/tmp/ansible-tmp-1713969894.262415-1346142-167829676315139/AnsiballZ_grafana_user.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/segu/.ansible/tmp/ansible-tmp-1713969894.262415-1346142-167829676315139/AnsiballZ_grafana_user.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.grafana.plugins.modules.grafana_user', init_globals=dict(_module_fqn='ansible_collections.community.grafana.plugins.modules.grafana_user', _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_community.grafana.grafana_user_payload_vtib7xty/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 323, in \n File \"/tmp/ansible_community.grafana.grafana_user_payload_vtib7xty/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 292, in main\n File \"/tmp/ansible_community.grafana.grafana_user_payload_vtib7xty/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 221, in get_user_from_login\n File \"/tmp/ansible_community.grafana.grafana_user_payload_vtib7xty/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 204, in _send_request\nAttributeError: 'NoneType' object has no attribute 'read'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
< PLAY RECAP >
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0