]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5675] Resolve the problem of no logging paused state in waiting state.
authorMarcin Siodelski <marcin@isc.org>
Thu, 19 Jul 2018 13:23:51 +0000 (15:23 +0200)
committerMarcin Siodelski <marcin@isc.org>
Thu, 19 Jul 2018 13:23:51 +0000 (15:23 +0200)
src/hooks/dhcp/high_availability/ha_service.cc
src/hooks/dhcp/high_availability/ha_service.h

index 0f7a608819eaba7d9c70899776c210aad181375f..288f9d762ac03b3b1c6b668404933e063950d234 100644 (file)
@@ -123,6 +123,9 @@ HAService::backupStateHandler() {
     if (doOnEntry()) {
         query_filter_.serveNoScopes();
         adjustNetworkState();
+
+        // Log if the state machine is paused.
+        conditionalLogPausedState();
     }
 
     // There is nothing to do in that state. This server simply receives
@@ -138,6 +141,9 @@ HAService::normalStateHandler() {
     if (doOnEntry()) {
         query_filter_.serveDefaultScopes();
         adjustNetworkState();
+
+        // Log if the state machine is paused.
+        conditionalLogPausedState();
     }
 
     scheduleHeartbeat();
@@ -193,6 +199,9 @@ HAService::partnerDownStateHandler() {
             query_filter_.serveDefaultScopes();
         }
         adjustNetworkState();
+
+        // Log if the state machine is paused.
+        conditionalLogPausedState();
     }
 
     scheduleHeartbeat();
@@ -238,6 +247,9 @@ HAService::readyStateHandler() {
     if (doOnEntry()) {
         query_filter_.serveNoScopes();
         adjustNetworkState();
+
+        // Log if the state machine is paused.
+        conditionalLogPausedState();
     }
 
     scheduleHeartbeat();
@@ -300,6 +312,9 @@ HAService::syncingStateHandler() {
     if (doOnEntry()) {
         query_filter_.serveNoScopes();
         adjustNetworkState();
+
+        // Log if the state machine is paused.
+        conditionalLogPausedState();
     }
 
     if (isModelPaused()) {
@@ -375,6 +390,9 @@ HAService::terminatedStateHandler() {
         // In the terminated state we don't send heartbeat.
         communication_state_->stopHeartbeat();
 
+        // Log if the state machine is paused.
+        conditionalLogPausedState();
+
         LOG_ERROR(ha_logger, HA_TERMINATED);
     }
 
@@ -389,6 +407,9 @@ HAService::waitingStateHandler() {
     if (doOnEntry()) {
         query_filter_.serveNoScopes();
         adjustNetworkState();
+
+        // Log if the state machine is paused.
+        conditionalLogPausedState();
     }
 
     // Only schedule the heartbeat for non-backup servers.
@@ -511,14 +532,6 @@ HAService::verboseTransition(const unsigned state) {
                 .arg(new_state_name);
         }
     }
-
-    // Inform the administrator if the state machine is paused.
-    if (isModelPaused()) {
-        std::string state_name = stateToString(state);
-        boost::to_upper(state_name);
-        LOG_INFO(ha_logger, HA_STATE_MACHINE_PAUSED)
-            .arg(state_name);
-    }
 }
 
 bool
@@ -531,6 +544,17 @@ HAService::unpause() {
     return (false);
 }
 
+void
+HAService::conditionalLogPausedState() const {
+    // Inform the administrator if the state machine is paused.
+    if (isModelPaused()) {
+        std::string state_name = stateToString(getCurrState());
+        boost::to_upper(state_name);
+        LOG_INFO(ha_logger, HA_STATE_MACHINE_PAUSED)
+            .arg(state_name);
+    }
+}
+
 void
 HAService::serveDefaultScopes() {
     query_filter_.serveDefaultScopes();
index 40e842f6021d6825d9496ef1e37af99aa571da53..58a2d6c83e8880565411413608d8d6940a68eecd 100644 (file)
@@ -255,6 +255,16 @@ public:
     /// machine was not paused when this method was invoked.
     bool unpause();
 
+protected:
+
+    /// @brief Logs if the server is paused in the current state.
+    ///
+    /// This method is internally called by the state handlers upon
+    /// entry to a new state.
+    void conditionalLogPausedState() const;
+
+public:
+
     /// @brief Instructs the HA service to serve default scopes.
     ///
     /// This method is mostly useful for unit testing. The scopes need to be