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

Zabbix modules are leaving open sessions behind themselves #58459

Closed
D3DeFi opened this issue Jun 27, 2019 · 6 comments · Fixed by #58525

Comments

@D3DeFi
Copy link
Contributor

commented Jun 27, 2019

SUMMARY

Issue was first reported for zabbix_proxy module in #58066 and fix was proposed in #58393.

However, this problem is present in all other zabbix_* modules too.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

zabbix_action
zabbix_group_info
zabbix_group
zabbix_host_info
zabbix_hostmacro
zabbix_host
zabbix_maintenance
zabbix_map
zabbix_mediatype
zabbix_screen
zabbix_template

ANSIBLE VERSION
ansible 2.9.0.dev0
  config file = None
  configured module search path = [u'/home/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/root/dedefi-ansible-fork/lib/ansible
  executable location = /home/root/dedefi-ansible-fork/bin/ansible
  python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516]
STEPS TO REPRODUCE

Run any zabbix module and then query Zabbix server database:

mysql> select * from sessions;
EXPECTED RESULTS

Zabbix module logouts first when exiting or throwing error.

ACTUAL RESULTS

Lots of opened sessions present in Zabbix server database.

+----------------------------------+--------+------------+--------+
| sessionid                        | userid | lastaccess | status |
+----------------------------------+--------+------------+--------+
| fc4f10f67c6a8f76b8461e42fe07843c |      1 | 1561639244 |      0 |
| 965c13c7d37519837d40197300a4f431 |      1 | 1561639331 |      0 |
| 7a4871bd5dd34df9862d2505e49891d0 |      1 | 1561639383 |      0 |
| 4a3b398f85c93322916f9120c60c754a |      1 | 1561639630 |      0 |
| bddcc072fdfa3fb2f55ff3ab627bbf8a |      1 | 1561639838 |      0 |
| 874767447dcb381dc33bad41595b5d8d |      1 | 1561639931 |      0 |
| adc9d0d28469c33750340030b158b8d3 |      1 | 1561639932 |      0 |
| 941600e03959dfb484f2ecbdddfe23b8 |      1 | 1561639933 |      0 |
| 054dbde03f8b1bbc56115baa2594135a |      1 | 1561639934 |      0 |
| 206814f513e89412fa73f1f3ba79e241 |      1 | 1561640419 |      0 |
| f77e2bfac3e192a05ac9d8cc36b51c08 |      1 | 1561640420 |      0 |
| d8c471a2eaa38d1e5a692af357a6beca |      1 | 1561640421 |      0 |
| 935265d95a380586ded138e9148396a5 |      1 | 1561640422 |      0 |
| 03363aa51844d8dcfa912bc57a8c7050 |      1 | 1561640882 |      0 |

@okgolove

This comment has been minimized.

Copy link
Contributor

commented Jun 27, 2019

Hello @D3DeFi. I'm going to implement this one.
Do you have any ideas how to do it without putting zbx.logout() before every exit function? Or just put this one and do not reflect about it?

sky-joker added a commit to sky-joker/ansible that referenced this issue Jun 27, 2019
…er and add zabbix logout processing.

Fixed the following issue.

* ansible#58002
* ansible#58459
@D3DeFi

This comment has been minimized.

Copy link
Contributor Author

commented Jun 27, 2019

I've tried to browse through other modules and it seems that they are either:

  • not implementing it,
  • using xy.logout() with every raise Exception/exit_json/fail_json,
  • using try/finally to cover most of this in a single block (example).
  • using atexit module (this is the winner for me!)
@D3DeFi

This comment has been minimized.

Copy link
Contributor Author

commented Jun 27, 2019

Just to be sure, interaction between zbx.logout() and atexit would need to be tested so we can be sure a session gets deleted.

@okgolove

This comment has been minimized.

Copy link
Contributor

commented Jun 28, 2019

If only the was something like defer() in golang.

@sivel sivel removed the needs_triage label Jul 1, 2019
@ansible ansible locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants
You can’t perform that action at this time.