diff --git a/node-daemon/pvcnoded/Daemon.py b/node-daemon/pvcnoded/Daemon.py index 9ba83816..74eb880d 100644 --- a/node-daemon/pvcnoded/Daemon.py +++ b/node-daemon/pvcnoded/Daemon.py @@ -235,12 +235,12 @@ def entrypoint(): # Force into secondary coordinator state if needed try: - if this_node.router_state == "primary" and len(d_node) > 1: + if this_node.coordinator_state == "primary" and len(d_node) > 1: zkhandler.write([("base.config.primary_node", "none")]) logger.out("Waiting for primary migration", state="s") timeout = 240 count = 0 - while this_node.router_state != "secondary" and count < timeout: + while this_node.coordinator_state != "secondary" and count < timeout: sleep(0.5) count += 1 except Exception: @@ -431,7 +431,7 @@ def entrypoint(): if new_primary == "none": if ( this_node.daemon_state == "run" - and this_node.router_state + and this_node.coordinator_state not in ["primary", "takeover", "relinquish"] ): logger.out( @@ -477,7 +477,7 @@ def entrypoint(): state="i", ) elif new_primary == config["node_hostname"]: - if this_node.router_state == "secondary": + if this_node.coordinator_state == "secondary": # Wait for 0.5s to ensure other contentions time out, then take over sleep(0.5) zkhandler.write( @@ -489,7 +489,7 @@ def entrypoint(): ] ) else: - if this_node.router_state == "primary": + if this_node.coordinator_state == "primary": # Wait for 0.5s to ensure other contentions time out, then relinquish sleep(0.5) zkhandler.write( @@ -536,7 +536,7 @@ def entrypoint(): ) # Start primary functionality if ( - this_node.router_state == "primary" + this_node.coordinator_state == "primary" and d_network[network].nettype == "managed" ): d_network[network].createGateways() @@ -549,7 +549,7 @@ def entrypoint(): # TODO: Move this to the Network structure if d_network[network].nettype == "managed": # Stop primary functionality - if this_node.router_state == "primary": + if this_node.coordinator_state == "primary": d_network[network].stopDHCPServer() d_network[network].removeGateways() dns_aggregator.remove_network(d_network[network]) diff --git a/node-daemon/pvcnoded/objects/MonitoringInstance.py b/node-daemon/pvcnoded/objects/MonitoringInstance.py index dc4c5532..cef8444d 100644 --- a/node-daemon/pvcnoded/objects/MonitoringInstance.py +++ b/node-daemon/pvcnoded/objects/MonitoringInstance.py @@ -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", diff --git a/node-daemon/pvcnoded/objects/NodeInstance.py b/node-daemon/pvcnoded/objects/NodeInstance.py index a82aa329..bc88ae2f 100644 --- a/node-daemon/pvcnoded/objects/NodeInstance.py +++ b/node-daemon/pvcnoded/objects/NodeInstance.py @@ -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( """ diff --git a/node-daemon/pvcnoded/objects/VXNetworkInstance.py b/node-daemon/pvcnoded/objects/VXNetworkInstance.py index bdff21b1..292101dd 100644 --- a/node-daemon/pvcnoded/objects/VXNetworkInstance.py +++ b/node-daemon/pvcnoded/objects/VXNetworkInstance.py @@ -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( diff --git a/node-daemon/pvcnoded/util/keepalive.py b/node-daemon/pvcnoded/util/keepalive.py index 99056c59..e26179d1 100644 --- a/node-daemon/pvcnoded/util/keepalive.py +++ b/node-daemon/pvcnoded/util/keepalive.py @@ -98,7 +98,7 @@ def collect_ceph_stats(logger, config, zkhandler, this_node, queue): return # Primary-only functions - if this_node.router_state == "primary": + if this_node.coordinator_state == "primary": # Get Ceph status information (pretty) if debug: logger.out( @@ -417,7 +417,7 @@ def collect_ceph_stats(logger, config, zkhandler, this_node, queue): ) # Upload OSD data for the cluster (primary-only) - if this_node.router_state == "primary": + if this_node.coordinator_state == "primary": if debug: logger.out( "Trigger updates for each OSD", state="d", prefix="ceph-thread" @@ -679,9 +679,9 @@ def node_keepalive(logger, config, zkhandler, this_node, monitoring_instance): # Display node information to the terminal if config["log_keepalives"]: - if this_node.router_state == "primary": + if this_node.coordinator_state == "primary": cst_colour = logger.fmt_green - elif this_node.router_state == "secondary": + elif this_node.coordinator_state == "secondary": cst_colour = logger.fmt_blue else: cst_colour = logger.fmt_cyan @@ -692,7 +692,7 @@ def node_keepalive(logger, config, zkhandler, this_node, monitoring_instance): datetime.now(), logger.fmt_end, logger.fmt_bold + cst_colour, - this_node.router_state, + this_node.coordinator_state, logger.fmt_end, ), state="t", @@ -700,7 +700,7 @@ def node_keepalive(logger, config, zkhandler, this_node, monitoring_instance): # Set the migration selector in Zookeeper for clients to read if config["enable_hypervisor"]: - if this_node.router_state == "primary": + if this_node.coordinator_state == "primary": try: if ( zkhandler.read("base.config.migration_target_selector") @@ -723,7 +723,7 @@ def node_keepalive(logger, config, zkhandler, this_node, monitoring_instance): # Set the upstream IP in Zookeeper for clients to read if config["enable_networking"]: - if this_node.router_state == "primary": + if this_node.coordinator_state == "primary": try: if ( zkhandler.read("base.config.upstream_ip") @@ -757,7 +757,7 @@ def node_keepalive(logger, config, zkhandler, this_node, monitoring_instance): logger.out( "Ensure the primary key is properly set", state="d", prefix="main-thread" ) - if this_node.router_state == "primary": + if this_node.coordinator_state == "primary": if zkhandler.read("base.config.primary_node") != this_node.name: zkhandler.write([("base.config.primary_node", this_node.name)])