]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3655] Fix chicken-egg in state info
authorMarcin Siodelski <marcin@isc.org>
Thu, 28 Nov 2024 13:51:05 +0000 (14:51 +0100)
committerMarcin Siodelski <marcin@isc.org>
Wed, 4 Dec 2024 09:21:45 +0000 (10:21 +0100)
src/hooks/dhcp/high_availability/ha_service.cc

index d93b55639488c3f7181a4a3b260a140156f1f359..c2de6b958cb3d47fa51d4b5c9e7cfcc19a488e41 100644 (file)
@@ -2941,6 +2941,10 @@ HAService::processMaintenanceCancel() {
                              " partner-in-maintenance state."));
     }
 
+    // This is the state the server will transition to if the notification to the
+    // partner is successful.
+    int next_state = getPrevState() == HA_PARTNER_IN_MAINTENANCE_ST ? HA_WAITING_ST : getPrevState();
+
     HAConfig::PeerConfigPtr remote_config = config_->getFailoverPeerConfig();
 
     // Create HTTP/1.1 request including ha-maintenance-notify command
@@ -2950,7 +2954,9 @@ HAService::processMaintenanceCancel() {
          HostHttpHeader(remote_config->getUrl().getStrippedHostname()));
     remote_config->addBasicAuthHttpHeader(request);
     request->setBodyAsJson(CommandCreator::createMaintenanceNotify(config_->getThisServerName(),
-                                                                   true, getCurrState(), server_type_));
+                                                                   true,
+                                                                   next_state,
+                                                                   server_type_));
     request->finalize();
 
     // Response object should also be created because the HTTP client needs
@@ -3048,7 +3054,7 @@ HAService::processMaintenanceCancel() {
     // previous one. Avoid returning to the partner-in-maintenance if it was
     // the previous state.
     postNextEvent(HA_MAINTENANCE_CANCEL_EVT);
-    verboseTransition(getPrevState() == HA_PARTNER_IN_MAINTENANCE_ST ? HA_WAITING_ST : getPrevState());
+    verboseTransition(next_state);
     runModel(NOP_EVT);
 
     return (createAnswer(CONTROL_RESULT_SUCCESS,