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
Add new drained state #25115
Add new drained state #25115
Conversation
New 'drained' state allows to set haproxy servers to 'DRAIN' mode
@xp0
|
Currently there is a load balancing module for apache that actually has multiple states including 'drained' mode in addition to enabled/disabled (http://docs.ansible.com/ansible/apache2_mod_proxy_module.html). Of course an extra option would also work however I'm thinking that adding the 'drained' mode to the state param will allow us to maintain some degree of consistency across modules. |
👍 |
"drained" is imho not correct, it should be "drain" since the node is not drained yet. It's in the process of being drained. "drained" would be correct if the node is in drain mode and no sessions are alive on that node. |
@xp0 / @agx When we say Since this is nice to have feature and I love to admit in the current. |
@ravibhure It's not really enabled since it doesn't allow new connections, but its not really disabled either since the node is still up and will still handle traffic for the existing persistent connections. For the applications that use sessions this is important since changing the state of a running node straight to MAINT will cause the sessions to break (traffic is immediately re-routed to the other running nodes). I understand that you want to minimize the number of states, I'm just afraid of causing more confusion by over-simplifying it. Either way I'm happy we can discuss about it. @agx |
Perfect, I am certainly agree on few, but this is fine for now. Thanks @xp0 |
👍 |
So one thing is that only newer versions of haproxy ( >1.5 )support a state of "drain". So this won't work for those of us using rhel, that aren't compiling our own version of haproxy. Ideally you want to set the drain state of an lb for a period of time, then after that time switch a node to maintenance to disable the host. Basically give connection x amount of time to die off naturally then after that time kill it off. Which is why under my linked pr, drain is basically an intermediate state to the final desired state of maint. The approach that was taken allows older versions of haproxy to let active connections die off, then when a node has no active connections place it in maintenance mode, or place in maintenance mode after x amount of time. I would like if we could get the haproxy version and be able to handle the request for draining as good as possible for the version we are running against. Only commenting because we both had commits that will clash on "drain". |
Also, add note to docs that states 'drained only works on haproxy versions x and above' aside from handling it in code |
@krislindgren For now I plan to check how to get the haproxy version and verify if it supports the DRAIN state (>=1.5). |
The test
|
I added the check for haproxy version, I suppose code could use some scrutiny |
@ravibhure ready for merge? |
@resmo good to go 👍 |
SUMMARY
New 'drained' state allows to set haproxy servers to 'DRAIN' mode
ISSUE TYPE
COMPONENT NAME
haproxy module (haproxy.py)
ANSIBLE VERSION
ADDITIONAL INFORMATION
The haproxy module was missing the ability to set servers in DRAIN mode, only UP (enabled) and MAINT (disabled) were supported.