Use coordinator_state instead of router_state
Makes it much clearer what this variable represents.
This commit is contained in:
@ -368,7 +368,7 @@ class MonitoringInstance(object):
|
||||
def run_plugin(self, plugin):
|
||||
time_start = datetime.now()
|
||||
try:
|
||||
result = plugin.run(coordinator_state=self.this_node.router_state)
|
||||
result = plugin.run(coordinator_state=self.this_node.coordinator_state)
|
||||
except Exception as e:
|
||||
self.logger.out(
|
||||
f"Monitoring plugin {plugin.plugin_name} failed: {type(e).__name__}: {e}",
|
||||
@ -384,9 +384,9 @@ class MonitoringInstance(object):
|
||||
return result
|
||||
|
||||
def run_plugins(self):
|
||||
if self.this_node.router_state == "primary":
|
||||
if self.this_node.coordinator_state == "primary":
|
||||
cst_colour = self.logger.fmt_green
|
||||
elif self.this_node.router_state == "secondary":
|
||||
elif self.this_node.coordinator_state == "secondary":
|
||||
cst_colour = self.logger.fmt_blue
|
||||
else:
|
||||
cst_colour = self.logger.fmt_cyan
|
||||
@ -398,7 +398,7 @@ class MonitoringInstance(object):
|
||||
datetime.now(),
|
||||
self.logger.fmt_end,
|
||||
self.logger.fmt_bold + cst_colour,
|
||||
self.this_node.router_state,
|
||||
self.this_node.coordinator_state,
|
||||
self.logger.fmt_end,
|
||||
),
|
||||
state="t",
|
||||
|
@ -52,7 +52,7 @@ class NodeInstance(object):
|
||||
# States
|
||||
self.daemon_mode = self.zkhandler.read(("node.mode", self.name))
|
||||
self.daemon_state = "stop"
|
||||
self.router_state = "client"
|
||||
self.coordinator_state = "client"
|
||||
self.domain_state = "flushed"
|
||||
# Object lists
|
||||
self.d_node = d_node
|
||||
@ -149,10 +149,10 @@ class NodeInstance(object):
|
||||
|
||||
if self.name == self.this_node and self.daemon_mode == "coordinator":
|
||||
# We're a coordinator so we care about networking
|
||||
if data != self.router_state:
|
||||
self.router_state = data
|
||||
if data != self.coordinator_state:
|
||||
self.coordinator_state = data
|
||||
if self.config["enable_networking"]:
|
||||
if self.router_state == "takeover":
|
||||
if self.coordinator_state == "takeover":
|
||||
self.logger.out(
|
||||
"Setting node {} to primary state".format(self.name),
|
||||
state="i",
|
||||
@ -161,7 +161,7 @@ class NodeInstance(object):
|
||||
target=self.become_primary, args=(), kwargs={}
|
||||
)
|
||||
transition_thread.start()
|
||||
if self.router_state == "relinquish":
|
||||
if self.coordinator_state == "relinquish":
|
||||
# Skip becoming secondary unless already running
|
||||
if (
|
||||
self.daemon_state == "run"
|
||||
@ -539,7 +539,7 @@ class NodeInstance(object):
|
||||
tick = 1
|
||||
patroni_failed = True
|
||||
# As long as we're in takeover, keep trying to set the Patroni leader to us
|
||||
while self.router_state == "takeover":
|
||||
while self.coordinator_state == "takeover":
|
||||
# Switch Patroni leader to the local instance
|
||||
retcode, stdout, stderr = common.run_os_command(
|
||||
"""
|
||||
|
@ -306,11 +306,11 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
|
||||
|
||||
if data and self.ip6_gateway != data.decode("ascii"):
|
||||
orig_gateway = self.ip6_gateway
|
||||
if self.this_node.router_state in ["primary", "takeover"]:
|
||||
if self.this_node.coordinator_state in ["primary", "takeover"]:
|
||||
if orig_gateway:
|
||||
self.removeGateway6Address()
|
||||
self.ip6_gateway = data.decode("ascii")
|
||||
if self.this_node.router_state in ["primary", "takeover"]:
|
||||
if self.this_node.coordinator_state in ["primary", "takeover"]:
|
||||
self.createGateway6Address()
|
||||
if self.dhcp_server_daemon:
|
||||
self.stopDHCPServer()
|
||||
@ -333,13 +333,13 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
|
||||
if (
|
||||
self.dhcp6_flag
|
||||
and not self.dhcp_server_daemon
|
||||
and self.this_node.router_state in ["primary", "takeover"]
|
||||
and self.this_node.coordinator_state in ["primary", "takeover"]
|
||||
):
|
||||
self.startDHCPServer()
|
||||
elif (
|
||||
self.dhcp_server_daemon
|
||||
and not self.dhcp4_flag
|
||||
and self.this_node.router_state in ["primary", "takeover"]
|
||||
and self.this_node.coordinator_state in ["primary", "takeover"]
|
||||
):
|
||||
self.stopDHCPServer()
|
||||
|
||||
@ -371,11 +371,11 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
|
||||
|
||||
if data and self.ip4_gateway != data.decode("ascii"):
|
||||
orig_gateway = self.ip4_gateway
|
||||
if self.this_node.router_state in ["primary", "takeover"]:
|
||||
if self.this_node.coordinator_state in ["primary", "takeover"]:
|
||||
if orig_gateway:
|
||||
self.removeGateway4Address()
|
||||
self.ip4_gateway = data.decode("ascii")
|
||||
if self.this_node.router_state in ["primary", "takeover"]:
|
||||
if self.this_node.coordinator_state in ["primary", "takeover"]:
|
||||
self.createGateway4Address()
|
||||
if self.dhcp_server_daemon:
|
||||
self.stopDHCPServer()
|
||||
@ -398,13 +398,13 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
|
||||
if (
|
||||
self.dhcp4_flag
|
||||
and not self.dhcp_server_daemon
|
||||
and self.this_node.router_state in ["primary", "takeover"]
|
||||
and self.this_node.coordinator_state in ["primary", "takeover"]
|
||||
):
|
||||
self.startDHCPServer()
|
||||
elif (
|
||||
self.dhcp_server_daemon
|
||||
and not self.dhcp6_flag
|
||||
and self.this_node.router_state in ["primary", "takeover"]
|
||||
and self.this_node.coordinator_state in ["primary", "takeover"]
|
||||
):
|
||||
self.stopDHCPServer()
|
||||
|
||||
@ -450,7 +450,7 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
|
||||
if self.dhcp_reservations != new_reservations:
|
||||
old_reservations = self.dhcp_reservations
|
||||
self.dhcp_reservations = new_reservations
|
||||
if self.this_node.router_state in ["primary", "takeover"]:
|
||||
if self.this_node.coordinator_state in ["primary", "takeover"]:
|
||||
self.updateDHCPReservations(old_reservations, new_reservations)
|
||||
if self.dhcp_server_daemon:
|
||||
self.stopDHCPServer()
|
||||
@ -706,7 +706,7 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
|
||||
self.createGateway4Address()
|
||||
|
||||
def createGateway6Address(self):
|
||||
if self.this_node.router_state in ["primary", "takeover"]:
|
||||
if self.this_node.coordinator_state in ["primary", "takeover"]:
|
||||
self.logger.out(
|
||||
"Creating gateway {}/{} on interface {}".format(
|
||||
self.ip6_gateway, self.ip6_cidrnetmask, self.bridge_nic
|
||||
@ -719,7 +719,7 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
|
||||
)
|
||||
|
||||
def createGateway4Address(self):
|
||||
if self.this_node.router_state in ["primary", "takeover"]:
|
||||
if self.this_node.coordinator_state in ["primary", "takeover"]:
|
||||
self.logger.out(
|
||||
"Creating gateway {}/{} on interface {}".format(
|
||||
self.ip4_gateway, self.ip4_cidrnetmask, self.bridge_nic
|
||||
@ -733,7 +733,7 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
|
||||
|
||||
def startDHCPServer(self):
|
||||
if (
|
||||
self.this_node.router_state in ["primary", "takeover"]
|
||||
self.this_node.coordinator_state in ["primary", "takeover"]
|
||||
and self.nettype == "managed"
|
||||
):
|
||||
self.logger.out(
|
||||
|
Reference in New Issue
Block a user