unixsurfer / haproxytool

A tool to interact with HAProxy via stats socket
Apache License 2.0
85 stars 8 forks source link

Python KeyError - when listing all frontends or servers #2

Closed haimari closed 8 years ago

haimari commented 8 years ago

haproxytool server -l Traceback (most recent call last): File "/usr/local/bin/haproxytool", line 10, in sys.exit(main()) File "/usr/local/lib/python2.7/dist-packages/haproxytool/cli.py", line 42, in main call_main(sub_cmd) File "/usr/local/lib/python2.7/dist-packages/haproxytool/server.py", line 258, in main cmd = ServerCommand(hap, arguments) File "/usr/local/lib/python2.7/dist-packages/haproxytool/server.py", line 74, in init args['--backend']) File "/usr/local/lib/python2.7/dist-packages/haproxytool/server.py", line 80, in build_server_list for server in self.hap.servers(): File "/usr/local/lib/python2.7/dist-packages/haproxyadmin/haproxy.py", line 610, in servers servers = backend.servers() File "/usr/local/lib/python2.7/dist-packages/haproxyadmin/backend.py", line 116, in servers for server in backend.servers(name): File "/usr/local/lib/python2.7/dist-packages/haproxyadmin/internal.py", line 441, in servers servers = self.hap_process.servers_stats(self.name, self.iid) File "/usr/local/lib/python2.7/dist-packages/haproxyadmin/internal.py", line 379, in iid data = self.stats_data() File "/usr/local/lib/python2.7/dist-packages/haproxyadmin/internal.py", line 404, in stats_data data = self.hap_process.backends_stats()[self.name] KeyError: 'StgWebServers'

unixsurfer commented 8 years ago

Can you share your configuration? It will help me to identify the problem. why Python version are you using?

unixsurfer commented 8 years ago

I also need to know the version of haproxytool and haproxyadmin

unixsurfer commented 8 years ago

According to the code https://github.com/unixsurfer/haproxyadmin/blob/master/haproxyadmin/internal.py#L404 you shouldn't have received KeyError exception.

unixsurfer commented 8 years ago

https://github.com/unixsurfer/haproxyadmin/commit/09b79377df427fd5fc2086ec198e04258186926c fixed this by catching the KeyError exception. Please upgrade haproxyadmin library and retry.