unixsurfer / haproxyadmin

A python library to interact with HAProxy over UNIX socket
Apache License 2.0
113 stars 31 forks source link

connected_socket() sometimes times out #19

Closed crovner closed 3 years ago

crovner commented 3 years ago

Hey Pavlos,

How are you doing? I'm investigating a problem with haproxyadmin, which sometimes fails to send commands through the socket. It turns out to be the function connected_socket() in utils.py, which has a hardcoded timeout of 0.1 seconds. It wouldn't be a problem if the function only opened a connection. But it does more than that; it also sends a show info command and expects a response. Sometimes we don't get a response in time, causing this function to fail.

I'm considering submitting a patch to make this timeout configurable. I would add a parameter to the constructor of the HAProxy class, similar to retry and retry_interval. This param could also be passed along to HAProxyProcess so it can be used when sending other commands (see internal.py file, line 82), for consistency.

Does it make sense?

unixsurfer commented 3 years ago

Hi @crovner,

I am fine, I hope the same for you and your family.

Your proposal makes sense, and you are correct by saying that connected_socket() does too much.

crovner commented 3 years ago

Thanks for the quick reply! I was looking at the previous version, so I didn't notice you had already created the timeout parameter. So my patch only makes connected_socket() use it.

unixsurfer commented 3 years ago

I have merged the #20, do you know how you can make a release?

crovner commented 3 years ago

Sure, I'll follow these steps to create a release on my own branch and then submit a pull request. Correct?

unixsurfer commented 3 years ago

Sure, I'll follow these steps to create a release on my own branch and then submit a pull request. Correct?

Yes, but the tagging is for the master branch, so you don't need to add it to the branch/PR. I will handle the tag.

crovner commented 3 years ago

OK, created MR #21