]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1024] Defined two new HA states
authorMarcin Siodelski <marcin@isc.org>
Mon, 13 Jan 2020 15:14:28 +0000 (16:14 +0100)
committerMarcin Siodelski <marcin@isc.org>
Mon, 27 Jan 2020 12:55:17 +0000 (13:55 +0100)
The new states are:
- partner-maintained
- maintained

src/hooks/dhcp/high_availability/ha_service.cc
src/hooks/dhcp/high_availability/ha_service.h
src/hooks/dhcp/high_availability/ha_service_states.cc
src/hooks/dhcp/high_availability/ha_service_states.h

index 5fd203c6c9dae99cf4d4a78f88fda46381cf4cab..eb5c3577662f8c1df794d3d5ddd18bf2d912985c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -99,10 +99,18 @@ HAService::defineStates() {
                 boost::bind(&HAService::normalStateHandler, this),
                 config_->getStateMachineConfig()->getStateConfig(HA_LOAD_BALANCING_ST)->getPausing());
 
+    defineState(HA_MAINTAINED_ST, stateToString(HA_MAINTAINED_ST),
+                boost::bind(&HAService::normalStateHandler, this),
+                config_->getStateMachineConfig()->getStateConfig(HA_MAINTAINED_ST)->getPausing());
+
     defineState(HA_PARTNER_DOWN_ST, stateToString(HA_PARTNER_DOWN_ST),
                 boost::bind(&HAService::partnerDownStateHandler, this),
                 config_->getStateMachineConfig()->getStateConfig(HA_PARTNER_DOWN_ST)->getPausing());
 
+    defineState(HA_PARTNER_MAINTAINED_ST, stateToString(HA_PARTNER_MAINTAINED_ST),
+                boost::bind(&HAService::partnerDownStateHandler, this),
+                config_->getStateMachineConfig()->getStateConfig(HA_PARTNER_MAINTAINED_ST)->getPausing());
+
     defineState(HA_READY_ST, stateToString(HA_READY_ST),
                 boost::bind(&HAService::readyStateHandler, this),
                 config_->getStateMachineConfig()->getStateConfig(HA_READY_ST)->getPausing());
index 6bd4ab8613bb28c80003786781432f781839de31..7f71333e90d4e76a66bc01d0c4c14a2ef4f54a60 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -141,6 +141,17 @@ public:
     /// it doesn't respond to heartbeats.
     void normalStateHandler();
 
+    /// @brief Handler for the "maintained" state.
+    ///
+    /// This is a handler invoked when one of the servers detected that
+    /// its partner is in the "partner-maintained" state. The server
+    /// being in this state is awaiting the shutdown by the administrator.
+    /// The administrator shuts down the server to perform some planned
+    /// maintenance. Meanwhile, the partner being in the "partner-maintained"
+    /// state responds to all DHCP queries. The server being in the
+    /// "maintained" state responds to no DHCP queries.
+    void maintainedStateHandler();
+
     /// @brief Handler for "partner-down" state.
     ///
     /// This is a handler invoked for the server which detected a failure
@@ -167,6 +178,28 @@ public:
     /// to the "waiting" state to try to resolve the conflict with the partner.
     void partnerDownStateHandler();
 
+    /// @brief Handler for "partner-maintained" state.
+    ///
+    /// This is a handler invoked for the server which was administratively
+    /// transitioned to the "partner-maintained" state. This is the case
+    /// when the partner needs to be shutdown for some planned maintenance.
+    ///
+    /// The server receiving ha-maintenance-start command transitions to this
+    /// state. It sends the ha-maintenance-notify command to the partner to cause
+    /// the partner to stop responding to the DHCP queries. Next, this server
+    /// starts responding to all DHCP queries. This allows the server
+    /// administrator to safely shutdown the partner as it is no longer
+    /// responsible for any portion of the DHCP traffic.
+    ///
+    /// The server being in the "partner-maintained" state remains in this
+    /// state until the first unsuccessful lease update, ha-heartbeat or any
+    /// other command send to the partner due to the issues with communication.
+    /// In that case the server assumes that the partner has been shutdown
+    /// and transitions to the "partner-down" state in which it still responds
+    /// to all DHCP queries but doesn't attempt to send lease updates to the
+    /// offline partner.
+    void partnerMaintainedStateHandler();
+
     /// @brief Handler for "ready" state.
     ///
     /// This a handler invoked for the server which finished synchronizing
index 50f5a5b0cade957d6cda0218ce6ecda34ae73d87..bb83dd5e8e5d467ccf8827060f66b712e890e4b7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -17,8 +17,12 @@ std::string stateToString(int state) {
         return ("hot-standby");
     case HA_LOAD_BALANCING_ST:
         return ("load-balancing");
+    case HA_MAINTAINED_ST:
+        return ("maintained");
     case HA_PARTNER_DOWN_ST:
         return ("partner-down");
+    case HA_PARTNER_MAINTAINED_ST:
+        return ("partner-maintained");
     case HA_READY_ST:
         return ("ready");
     case HA_SYNCING_ST:
@@ -46,9 +50,15 @@ int stringToState(const std::string& state_name) {
     } else if (state_name == "load-balancing") {
         return (HA_LOAD_BALANCING_ST);
 
+    } else if (state_name == "maintained") {
+        return (HA_MAINTAINED_ST);
+
     } else if (state_name == "partner-down") {
         return (HA_PARTNER_DOWN_ST);
 
+    } else if (state_name == "partner-maintained") {
+        return (HA_PARTNER_MAINTAINED_ST);
+
     } else if (state_name == "ready") {
         return (HA_READY_ST);
 
index f3e8af4733dcc75875db399e475c799ed03f2912..f7d09ad4764f33745edb5bbb6920107df51d76dd 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -22,20 +22,26 @@ const int HA_HOT_STANDBY_ST = util::StateModel::SM_DERIVED_STATE_MIN + 2;
 /// Load balancing state.
 const int HA_LOAD_BALANCING_ST = util::StateModel::SM_DERIVED_STATE_MIN + 3;
 
+/// Maintainedo state.
+const int HA_MAINTAINED_ST = util::StateModel::SM_DERIVED_STATE_MIN + 4;
+
 /// Partner down state.
-const int HA_PARTNER_DOWN_ST = util::StateModel::SM_DERIVED_STATE_MIN + 4;
+const int HA_PARTNER_DOWN_ST = util::StateModel::SM_DERIVED_STATE_MIN + 5;
+
+/// Partner maintained state.
+const int HA_PARTNER_MAINTAINED_ST = util::StateModel::SM_DERIVED_STATE_MIN + 6;
 
 /// Server ready state, i.e. synchronized database, can enable DHCP service.
-const int HA_READY_ST = util::StateModel::SM_DERIVED_STATE_MIN + 5;
+const int HA_READY_ST = util::StateModel::SM_DERIVED_STATE_MIN + 7;
 
 /// Synchronizing database state.
-const int HA_SYNCING_ST = util::StateModel::SM_DERIVED_STATE_MIN + 6;
+const int HA_SYNCING_ST = util::StateModel::SM_DERIVED_STATE_MIN + 8;
 
 /// HA service terminated state.
-const int HA_TERMINATED_ST = util::StateModel::SM_DERIVED_STATE_MIN + 7;
+const int HA_TERMINATED_ST = util::StateModel::SM_DERIVED_STATE_MIN + 9;
 
 /// Server waiting state, i.e. waiting for another server to be ready.
-const int HA_WAITING_ST = util::StateModel::SM_DERIVED_STATE_MIN + 8;
+const int HA_WAITING_ST = util::StateModel::SM_DERIVED_STATE_MIN + 10;
 
 /// Special state indicating that this server is unable to communicate with
 /// the partner.