]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5674] State machine pausing dealt with in transition.
authorMarcin Siodelski <marcin@isc.org>
Wed, 18 Jul 2018 11:31:10 +0000 (13:31 +0200)
committerMarcin Siodelski <marcin@isc.org>
Wed, 18 Jul 2018 11:31:10 +0000 (13:31 +0200)
src/hooks/dhcp/high_availability/ha_service.cc
src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc

index 8546dab1c49e7e6c8b50d08ccd4974c039373097..e1257c8bc057ff4b1e5d634d3e62b544321b55c5 100644 (file)
@@ -55,6 +55,7 @@ HAService::HAService(const IOServicePtr& io_service, const NetworkStatePtr& netw
     }
 
     startModel(HA_WAITING_ST);
+    state_machine_control_.notify(HA_WAITING_ST);
 
     LOG_INFO(ha_logger, HA_SERVICE_STARTED)
         .arg(HAConfig::HAModeToString(config->getHAMode()))
@@ -115,7 +116,6 @@ HAService::backupStateHandler() {
     if (doOnEntry()) {
         query_filter_.serveNoScopes();
         adjustNetworkState();
-        state_machine_control_.notify(getCurrState());
     }
 
     // There is nothing to do in that state. This server simply receives
@@ -131,7 +131,6 @@ HAService::normalStateHandler() {
     if (doOnEntry()) {
         query_filter_.serveDefaultScopes();
         adjustNetworkState();
-        state_machine_control_.notify(getCurrState());
     }
 
     scheduleHeartbeat();
@@ -187,8 +186,6 @@ HAService::partnerDownStateHandler() {
             query_filter_.serveDefaultScopes();
         }
         adjustNetworkState();
-
-        state_machine_control_.notify(getCurrState());
     }
 
     scheduleHeartbeat();
@@ -234,7 +231,6 @@ HAService::readyStateHandler() {
     if (doOnEntry()) {
         query_filter_.serveNoScopes();
         adjustNetworkState();
-        state_machine_control_.notify(getCurrState());
     }
 
     scheduleHeartbeat();
@@ -297,7 +293,6 @@ HAService::syncingStateHandler() {
     if (doOnEntry()) {
         query_filter_.serveNoScopes();
         adjustNetworkState();
-        state_machine_control_.notify(getCurrState());
     }
 
     if (state_machine_control_.amPaused()) {
@@ -369,7 +364,6 @@ HAService::terminatedStateHandler() {
     if (doOnEntry()) {
         query_filter_.serveDefaultScopes();
         adjustNetworkState();
-        state_machine_control_.notify(getCurrState());
 
         // In the terminated state we don't send heartbeat.
         communication_state_->stopHeartbeat();
@@ -388,7 +382,6 @@ HAService::waitingStateHandler() {
     if (doOnEntry()) {
         query_filter_.serveNoScopes();
         adjustNetworkState();
-        state_machine_control_.notify(getCurrState());
     }
 
     // Only schedule the heartbeat for non-backup servers.
@@ -489,6 +482,7 @@ HAService::verboseTransition(const unsigned state) {
 
     // Do the actual transition.
     transition(state, getNextEvent());
+    state_machine_control_.notify(state);
 
     // Inform the administrator whether or not lease updates are generated.
     // Updates are never generated by a backup server so it doesn't make
index 12b7bbd52591b4f00a193618c619f8050d754654..829cb746c095f320812f4933f1c6da3c4d09bf58 100644 (file)
@@ -3559,6 +3559,8 @@ TEST_F(HAServiceStateMachineTest, stateTransitionsLoadBalancingPause) {
     state_machine->getStateConfig(HA_LOAD_BALANCING_ST)->setPausing("always");
     state_machine->getStateConfig(HA_PARTNER_DOWN_ST)->setPausing("always");
     state_machine->getStateConfig(HA_READY_ST)->setPausing("always");
+    state_machine->getStateConfig(HA_SYNCING_ST)->setPausing("always");
+    state_machine->getStateConfig(HA_TERMINATED_ST)->setPausing("always");
     state_machine->getStateConfig(HA_WAITING_ST)->setPausing("always");
 
     startService(valid_config);
@@ -3619,9 +3621,15 @@ TEST_F(HAServiceStateMachineTest, stateTransitionsLoadBalancingPause) {
 TEST_F(HAServiceStateMachineTest, syncingTransitionsLoadBalancingPause) {
     HAConfigPtr valid_config = createValidConfiguration();
 
-    // Pause state machine in syncing state.
-    auto state_config = valid_config->getStateMachineConfig()->getStateConfig(HA_SYNCING_ST);
-    state_config->setPausing("always");
+    auto state_machine = valid_config->getStateMachineConfig();
+
+    // Pause state machine in various states.
+    state_machine->getStateConfig(HA_LOAD_BALANCING_ST)->setPausing("always");
+    state_machine->getStateConfig(HA_PARTNER_DOWN_ST)->setPausing("always");
+    state_machine->getStateConfig(HA_READY_ST)->setPausing("always");
+    state_machine->getStateConfig(HA_SYNCING_ST)->setPausing("always");
+    state_machine->getStateConfig(HA_TERMINATED_ST)->setPausing("always");
+    state_machine->getStateConfig(HA_WAITING_ST)->setPausing("always");
 
     startService(valid_config);
     waitForEvent(HAService::HA_HEARTBEAT_COMPLETE_EVT);