Commit c793cdb4 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[#689] Include error messages for lease updates in the log.

parent 59782988
// File created from ../../../../src/hooks/dhcp/high_availability/ha_messages.mes on Mon Jun 24 2019 12:19 // File created from ../../../../src/hooks/dhcp/high_availability/ha_messages.mes on Mon Jun 24 2019 17:05
#include <cstddef> #include <cstddef>
#include <log/message_types.h> #include <log/message_types.h>
...@@ -120,8 +120,8 @@ const char* values[] = { ...@@ -120,8 +120,8 @@ const char* values[] = {
"HA_LEASE_UPDATES_DISABLED", "lease updates will not be sent to the partner while in %1 state", "HA_LEASE_UPDATES_DISABLED", "lease updates will not be sent to the partner while in %1 state",
"HA_LEASE_UPDATES_ENABLED", "lease updates will be sent to the partner while in %1 state", "HA_LEASE_UPDATES_ENABLED", "lease updates will be sent to the partner while in %1 state",
"HA_LEASE_UPDATE_COMMUNICATIONS_FAILED", "%1: failed to communicate with %2: %3", "HA_LEASE_UPDATE_COMMUNICATIONS_FAILED", "%1: failed to communicate with %2: %3",
"HA_LEASE_UPDATE_CREATE_UPDATE_FAILED_ON_PEER", "%1: failed to create or update the lease having type %2 for address %3 in subnet %4", "HA_LEASE_UPDATE_CREATE_UPDATE_FAILED_ON_PEER", "%1: failed to create or update the lease having type %2 for address %3, reason: %4",
"HA_LEASE_UPDATE_DELETE_FAILED_ON_PEER", "%1: failed to delete the lease having type %2 for address %3 in subnet %4", "HA_LEASE_UPDATE_DELETE_FAILED_ON_PEER", "%1: failed to delete the lease having type %2 for address %3, reason: %4",
"HA_LEASE_UPDATE_FAILED", "%1: lease update to %2 failed: %3", "HA_LEASE_UPDATE_FAILED", "%1: lease update to %2 failed: %3",
"HA_LOAD_BALANCING_DUID_MISSING", "load balancing failed for the DHCPv6 message (transaction id: %1) because DUID is missing", "HA_LOAD_BALANCING_DUID_MISSING", "load balancing failed for the DHCPv6 message (transaction id: %1) because DUID is missing",
"HA_LOAD_BALANCING_IDENTIFIER_MISSING", "load balancing failed for the DHCPv4 message (transaction id: %1) because HW address and client identifier are missing", "HA_LOAD_BALANCING_IDENTIFIER_MISSING", "load balancing failed for the DHCPv4 message (transaction id: %1) because HW address and client identifier are missing",
......
// File created from ../../../../src/hooks/dhcp/high_availability/ha_messages.mes on Mon Jun 24 2019 12:19 // File created from ../../../../src/hooks/dhcp/high_availability/ha_messages.mes on Mon Jun 24 2019 17:05
#ifndef HA_MESSAGES_H #ifndef HA_MESSAGES_H
#define HA_MESSAGES_H #define HA_MESSAGES_H
......
...@@ -262,12 +262,12 @@ This warning message indicates that there was a problem in communication with a ...@@ -262,12 +262,12 @@ This warning message indicates that there was a problem in communication with a
HA peer while processing a DHCP client query and sending lease update. The HA peer while processing a DHCP client query and sending lease update. The
client's DHCP message will be dropped. client's DHCP message will be dropped.
% HA_LEASE_UPDATE_DELETE_FAILED_ON_PEER %1: failed to delete the lease having type %2 for address %3 in subnet %4 % HA_LEASE_UPDATE_DELETE_FAILED_ON_PEER %1: failed to delete the lease having type %2 for address %3, reason: %4
This informational message is issued when one of the leases failed to delete This informational message is issued when one of the leases failed to delete
on the HA peer while processing lease updates sent from this server. Typically, on the HA peer while processing lease updates sent from this server. Typically,
the lease fails to delete when it doesn't exist in the peer's database. the lease fails to delete when it doesn't exist in the peer's database.
% HA_LEASE_UPDATE_CREATE_UPDATE_FAILED_ON_PEER %1: failed to create or update the lease having type %2 for address %3 in subnet %4 % HA_LEASE_UPDATE_CREATE_UPDATE_FAILED_ON_PEER %1: failed to create or update the lease having type %2 for address %3, reason: %4
This informational message is issued when one of the leases failed to be This informational message is issued when one of the leases failed to be
created or updated on the HA peer whilw processing the lease updates sent created or updated on the HA peer whilw processing the lease updates sent
from this server. This may indicate an issue with communication between from this server. This may indicate an issue with communication between
......
...@@ -916,28 +916,24 @@ HAService::logFailedLeaseUpdates(const PktPtr& query, ...@@ -916,28 +916,24 @@ HAService::logFailedLeaseUpdates(const PktPtr& query,
for (int i = 0; i < failed_leases->size(); ++i) { for (int i = 0; i < failed_leases->size(); ++i) {
auto lease = failed_leases->get(i); auto lease = failed_leases->get(i);
if (lease->getType() == Element::map) { if (lease->getType() == Element::map) {
// subnet-id
auto subnet_id = lease->get("subnet-id");
std::ostringstream subnet_id_text;
if (subnet_id && subnet_id->getType() == Element::integer) {
subnet_id_text << subnet_id->intValue();
} else {
subnet_id_text << "(unknown)";
}
// ip-address // ip-address
auto ip_address = lease->get("ip-address"); auto ip_address = lease->get("ip-address");
// lease type // lease type
auto lease_type = lease->get("type"); auto lease_type = lease->get("type");
// error-message
auto error_message = lease->get("error-message");
LOG_INFO(ha_logger, mesid) LOG_INFO(ha_logger, mesid)
.arg(query->getLabel()) .arg(query->getLabel())
.arg(lease_type && (lease_type->getType() == Element::string) ? .arg(lease_type && (lease_type->getType() == Element::string) ?
lease_type->stringValue() : "(uknown)") lease_type->stringValue() : "(uknown)")
.arg(ip_address && (ip_address->getType() == Element::string) ? .arg(ip_address && (ip_address->getType() == Element::string) ?
ip_address->stringValue() : "(unknown)") ip_address->stringValue() : "(unknown)")
.arg(subnet_id_text.str()); .arg(error_message && (error_message->getType() == Element::string) ?
error_message->stringValue() : "(unknown)");
} }
} }
} }
......
...@@ -1498,12 +1498,16 @@ TEST_F(HAServiceTest, sendUpdatesFailedLeases6) { ...@@ -1498,12 +1498,16 @@ TEST_F(HAServiceTest, sendUpdatesFailedLeases6) {
failed_deleted_lease->set("type", Element::create("IA_NA")); failed_deleted_lease->set("type", Element::create("IA_NA"));
failed_deleted_lease->set("ip-address", Element::create("2001:db8:1::1")); failed_deleted_lease->set("ip-address", Element::create("2001:db8:1::1"));
failed_deleted_lease->set("subnet-id", Element::create(1)); failed_deleted_lease->set("subnet-id", Element::create(1));
failed_deleted_lease->set("result", Element::create(CONTROL_RESULT_EMPTY));
failed_deleted_lease->set("error-message", Element::create("no lease found"));
// Crate a dummy lease which failed to be created. // Crate a dummy lease which failed to be created.
auto failed_lease = Element::createMap(); auto failed_lease = Element::createMap();
failed_lease->set("type", Element::create("IA_PD")); failed_lease->set("type", Element::create("IA_PD"));
failed_lease->set("ip-address", Element::create("2001:db8:1::")); failed_lease->set("ip-address", Element::create("2001:db8:1::"));
failed_lease->set("subnet-id", Element::create(2)); failed_lease->set("subnet-id", Element::create(2));
failed_lease->set("result", Element::create(CONTROL_RESULT_ERROR));
failed_lease->set("error-message", Element::create("failed to create lease"));
// Create the "failed-deleted-leases" list. // Create the "failed-deleted-leases" list.
auto failed_deleted_leases = Element::createList(); auto failed_deleted_leases = Element::createList();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment