Skip to content

Commit

Permalink
🐛 Fix server remove in haproxy while already exist
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
  • Loading branch information
mhkarimi1383 committed Nov 4, 2024
1 parent dcb9da2 commit 4afa304
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions charts/haproxy-redis-sentinel/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: haproxy-redis-sentinel
description: A Helm chart for HAProxy with Redis Sentinel
version: 0.0.7
appVersion: "0.0.4"
version: 0.0.8
appVersion: "0.0.5"

10 changes: 6 additions & 4 deletions haproxy_redis_sentinel/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ def run(
info(f"Setting initial master address: {address}")

# Remove server in case of restarts
out = send_command(haproxy_socket, f"del server {
haproxy_backend}/{haproxy_server_name}")
out = send_command(haproxy_socket, [
f"set server {
haproxy_backend}/{haproxy_server_name} state maint",
f"del server {haproxy_backend}/{haproxy_server_name}"])
if out not in {HAProxyOutput.SERVER_DELETED,
HAProxyOutput.SERVER_NOT_FOUND,
HAProxyOutput.BACKEND_NOT_FOUND}:
Expand All @@ -130,8 +132,8 @@ def run(
port = data[4]
info("Master Changed, Terminating clients")
info(send_command(haproxy_socket,
[f"set server {haproxy_backend}/current_master state maint",
f"shutdown sessions server {haproxy_backend}/current_master"]))
[f"set server {haproxy_backend}/{haproxy_server_name} state maint",
f"shutdown sessions server {haproxy_backend}/{haproxy_server_name}"])) # noqa: E501
info(f"Switching to new master Host: {host}, Port: {port}")
info(send_command(haproxy_socket,
f"set server {haproxy_backend}/{haproxy_server_name} addr {host} port {port} state ready")) # noqa: E501

0 comments on commit 4afa304

Please sign in to comment.