From: Razvan Becheriu Date: Wed, 12 Aug 2020 11:19:29 +0000 (+0300) Subject: [#1335] added try catch block and error message for lease reclamation X-Git-Tag: Kea-1.8.0~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3461781bf37880de17108f812ccf7c4df1db264;p=thirdparty%2Fkea.git [#1335] added try catch block and error message for lease reclamation --- diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 33efa9c503..45b4da3516 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -1118,10 +1118,14 @@ void ControlledDhcpv4Srv::reclaimExpiredLeases(const size_t max_leases, const uint16_t timeout, const bool remove_lease, - const uint16_t max_unwarned_cycles) { - server_->alloc_engine_->reclaimExpiredLeases4(max_leases, timeout, - remove_lease, - max_unwarned_cycles); + try { + server_->alloc_engine_->reclaimExpiredLeases4(max_leases, timeout, + remove_lease, + max_unwarned_cycles); + } catch (const std::exception& ex) { + LOG_ERROR(dhcp4_logger, DHCP4_RECLAIM_EXPIRED_LEASES_FAIL) + .arg(ex.what()); + } // We're using the ONE_SHOT timer so there is a need to re-schedule it. TimerMgr::instance()->setup(CfgExpiration::RECLAIM_EXPIRED_TIMER_NAME); } diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index 615d835a90..cfb510fa5c 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -433,6 +433,10 @@ and transaction identification information. The second argument contains the client's IPv4 address to which the response will be sent. The third argument contains the local interface name. +% DHCP4_RECLAIM_EXPIRED_LEASES_FAIL failed to reclaim expired leases: %1 +This error message indicates that the reclaim expired leases operation failed, +also providing the cause of failure. + % DHCP4_INIT_FAIL failed to initialize Kea server: %1 The server has failed to initialize. This may be because the configuration was not successful, or it encountered any other critical error on startup. diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index dd4bc17880..1b73cb83b3 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -1138,9 +1138,14 @@ ControlledDhcpv6Srv::reclaimExpiredLeases(const size_t max_leases, const uint16_t timeout, const bool remove_lease, const uint16_t max_unwarned_cycles) { - server_->alloc_engine_->reclaimExpiredLeases6(max_leases, timeout, - remove_lease, - max_unwarned_cycles); + try { + server_->alloc_engine_->reclaimExpiredLeases6(max_leases, timeout, + remove_lease, + max_unwarned_cycles); + } catch (const std::exception& ex) { + LOG_ERROR(dhcp6_logger, DHCP6_RECLAIM_EXPIRED_LEASES_FAIL) + .arg(ex.what()); + } // We're using the ONE_SHOT timer so there is a need to re-schedule it. TimerMgr::instance()->setup(CfgExpiration::RECLAIM_EXPIRED_TIMER_NAME); } diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index acd61759e6..14250768c4 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -436,6 +436,10 @@ will be only able to offer global options - no addresses or prefixes will be assigned. The argument holds the client and transaction identification information. +% DHCP6_RECLAIM_EXPIRED_LEASES_FAIL failed to reclaim expired leases: %1 +This error message indicates that the reclaim expired leases operation failed, +also providing the cause of failure. + % DHCP6_INIT_FAIL failed to initialize Kea server: %1 The server has failed to establish communication with the rest of Kea, failed to read JSON configuration file or encountered any other critical