]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3178] Log the number of applied leases
authorMarcin Siodelski <marcin@isc.org>
Tue, 2 Jan 2024 12:58:08 +0000 (13:58 +0100)
committerMarcin Siodelski <marcin@isc.org>
Fri, 5 Jan 2024 18:04:19 +0000 (19:04 +0100)
src/hooks/dhcp/high_availability/ha_messages.cc
src/hooks/dhcp/high_availability/ha_messages.h
src/hooks/dhcp/high_availability/ha_messages.mes
src/hooks/dhcp/high_availability/ha_service.cc

index be2e3705336ed7040cc35e7516650c6b1d99b840..e59517b97e2cade1c6d4635843eb64cc7cbe59bf 100644 (file)
@@ -61,6 +61,7 @@ extern const isc::log::MessageID HA_LEASES_BACKLOG_FAILED = "HA_LEASES_BACKLOG_F
 extern const isc::log::MessageID HA_LEASES_BACKLOG_NOTHING_TO_SEND = "HA_LEASES_BACKLOG_NOTHING_TO_SEND";
 extern const isc::log::MessageID HA_LEASES_BACKLOG_START = "HA_LEASES_BACKLOG_START";
 extern const isc::log::MessageID HA_LEASES_BACKLOG_SUCCESS = "HA_LEASES_BACKLOG_SUCCESS";
+extern const isc::log::MessageID HA_LEASES_SYNC_APPLIED_LEASES = "HA_LEASES_SYNC_APPLIED_LEASES";
 extern const isc::log::MessageID HA_LEASES_SYNC_COMMUNICATIONS_FAILED = "HA_LEASES_SYNC_COMMUNICATIONS_FAILED";
 extern const isc::log::MessageID HA_LEASES_SYNC_FAILED = "HA_LEASES_SYNC_FAILED";
 extern const isc::log::MessageID HA_LEASES_SYNC_LEASE_PAGE_RECEIVED = "HA_LEASES_SYNC_LEASE_PAGE_RECEIVED";
@@ -184,6 +185,7 @@ const char* values[] = {
     "HA_LEASES_BACKLOG_NOTHING_TO_SEND", "%1: no leases in backlog after communication recovery",
     "HA_LEASES_BACKLOG_START", "%1: starting to send %2 outstanding lease updates to %3",
     "HA_LEASES_BACKLOG_SUCCESS", "%1: sending lease updates backlog to %2 successful in %3",
+    "HA_LEASES_SYNC_APPLIED_LEASES", "%1: applied %2 leases received from the partner in the local lease database",
     "HA_LEASES_SYNC_COMMUNICATIONS_FAILED", "%1: failed to communicate with %2 while syncing leases: %3",
     "HA_LEASES_SYNC_FAILED", "%1: failed to synchronize leases with %2: %3",
     "HA_LEASES_SYNC_LEASE_PAGE_RECEIVED", "%1: received %2 leases from %3",
index e035793b29ed8c105b5962f7921a194d53b2be94..8a0c405c20561587e91803f21e93036bed151d90 100644 (file)
@@ -62,6 +62,7 @@ extern const isc::log::MessageID HA_LEASES_BACKLOG_FAILED;
 extern const isc::log::MessageID HA_LEASES_BACKLOG_NOTHING_TO_SEND;
 extern const isc::log::MessageID HA_LEASES_BACKLOG_START;
 extern const isc::log::MessageID HA_LEASES_BACKLOG_SUCCESS;
+extern const isc::log::MessageID HA_LEASES_SYNC_APPLIED_LEASES;
 extern const isc::log::MessageID HA_LEASES_SYNC_COMMUNICATIONS_FAILED;
 extern const isc::log::MessageID HA_LEASES_SYNC_FAILED;
 extern const isc::log::MessageID HA_LEASES_SYNC_LEASE_PAGE_RECEIVED;
index 09cb61f0abf170af12300d70f6e1ba004ae6be5c..8b2fbd5044e90e12ebad56cd6d6f9c415b786106 100644 (file)
@@ -339,6 +339,14 @@ local server's name. The second argument specifies the name of the remote server
 The third argument specifies the duration of
 this operation.
 
+% HA_LEASES_SYNC_APPLIED_LEASES %1: applied %2 leases received from the partner in the local lease database
+This informational message outputs the number of leases received from the
+partner during the database synchronization and applied in the local database.
+A typical case when only some leases are applied is when the server has
+multiple relationships and some of the received leases belong to another
+relationship. The first argument specifies this server name. The second
+argument specifies the number of applied leases.
+
 % HA_LEASES_SYNC_COMMUNICATIONS_FAILED %1: failed to communicate with %2 while syncing leases: %3
 This error message is issued to indicate that there was a communication error
 with a partner server while trying to fetch leases from its lease database.
index 1a538f06f718866d93666332fdd2700097aa5729..58f798b687ab4586786bb7a8127f5eab72301c7f 100644 (file)
@@ -2200,6 +2200,8 @@ HAService::asyncSyncLeasesInternal(http::HttpClient& http_client,
                         .arg(leases_element.size())
                         .arg(server_name);
 
+                    // Count actually applied leases.
+                    uint64_t applied_lease_count = 0;
                     for (auto l = leases_element.begin(); l != leases_element.end(); ++l) {
                         try {
 
@@ -2223,6 +2225,7 @@ HAService::asyncSyncLeasesInternal(http::HttpClient& http_client,
                                 if (!existing_lease) {
                                     // There is no such lease, so let's add it.
                                     LeaseMgrFactory::instance().addLease(lease);
+                                    ++applied_lease_count;
 
                                 } else if (existing_lease->cltt_ < lease->cltt_) {
                                     // If the existing lease is older than the fetched lease, update
@@ -2232,6 +2235,7 @@ HAService::asyncSyncLeasesInternal(http::HttpClient& http_client,
                                     // the current expiration time value does not match what is stored.
                                     Lease::syncCurrentExpirationTime(*existing_lease, *lease);
                                     LeaseMgrFactory::instance().updateLease4(lease);
+                                    ++applied_lease_count;
 
                                 } else {
                                     LOG_DEBUG(ha_logger, DBGLVL_TRACE_BASIC, HA_LEASE_SYNC_STALE_LEASE4_SKIP)
@@ -2261,6 +2265,7 @@ HAService::asyncSyncLeasesInternal(http::HttpClient& http_client,
                                 if (!existing_lease) {
                                     // There is no such lease, so let's add it.
                                     LeaseMgrFactory::instance().addLease(lease);
+                                    ++applied_lease_count;
 
                                 } else if (existing_lease->cltt_ < lease->cltt_) {
                                     // If the existing lease is older than the fetched lease, update
@@ -2270,6 +2275,7 @@ HAService::asyncSyncLeasesInternal(http::HttpClient& http_client,
                                     // the current expiration time value does not match what is stored.
                                     Lease::syncCurrentExpirationTime(*existing_lease, *lease);
                                     LeaseMgrFactory::instance().updateLease6(lease);
+                                    ++applied_lease_count;
 
                                 } else {
                                     LOG_DEBUG(ha_logger, DBGLVL_TRACE_BASIC, HA_LEASE_SYNC_STALE_LEASE6_SKIP)
@@ -2287,6 +2293,10 @@ HAService::asyncSyncLeasesInternal(http::HttpClient& http_client,
                         }
                     }
 
+                    LOG_INFO(ha_logger, HA_LEASES_SYNC_APPLIED_LEASES)
+                        .arg(config_->getThisServerName())
+                        .arg(applied_lease_count);
+
                 } catch (const std::exception& ex) {
                     error_message = ex.what();
                     LOG_ERROR(ha_logger, HA_LEASES_SYNC_FAILED)