mirror of https://github.com/Icinga/icinga2.git
Don't log messages we've already relayed to all relevant zones
fixes #10262
This commit is contained in:
parent
2c6a87576b
commit
3bfc9a2406
|
@ -584,9 +584,6 @@ void ApiListener::SyncRelayMessage(const MessageOrigin::Ptr& origin,
|
||||||
Log(LogNotice, "ApiListener")
|
Log(LogNotice, "ApiListener")
|
||||||
<< "Relaying '" << message->Get("method") << "' message";
|
<< "Relaying '" << message->Get("method") << "' message";
|
||||||
|
|
||||||
if (log)
|
|
||||||
PersistMessage(message, secobj);
|
|
||||||
|
|
||||||
if (origin && origin->FromZone)
|
if (origin && origin->FromZone)
|
||||||
message->Set("originZone", origin->FromZone->GetName());
|
message->Set("originZone", origin->FromZone->GetName());
|
||||||
|
|
||||||
|
@ -595,15 +592,31 @@ void ApiListener::SyncRelayMessage(const MessageOrigin::Ptr& origin,
|
||||||
Zone::Ptr my_zone = Zone::GetLocalZone();
|
Zone::Ptr my_zone = Zone::GetLocalZone();
|
||||||
|
|
||||||
std::vector<Endpoint::Ptr> skippedEndpoints;
|
std::vector<Endpoint::Ptr> skippedEndpoints;
|
||||||
|
std::set<Zone::Ptr> allZones;
|
||||||
std::set<Zone::Ptr> finishedZones;
|
std::set<Zone::Ptr> finishedZones;
|
||||||
|
std::set<Zone::Ptr> finishedLogZones;
|
||||||
|
|
||||||
BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType<Endpoint>()) {
|
BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType<Endpoint>()) {
|
||||||
/* don't relay messages to ourselves or disconnected endpoints */
|
/* don't relay messages to ourselves */
|
||||||
if (endpoint->GetName() == GetIdentity() || !endpoint->IsConnected())
|
if (endpoint->GetName() == GetIdentity())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Zone::Ptr target_zone = endpoint->GetZone();
|
Zone::Ptr target_zone = endpoint->GetZone();
|
||||||
|
|
||||||
|
allZones.insert(target_zone);
|
||||||
|
|
||||||
|
/* only relay messages to zones which have access to the object */
|
||||||
|
if (!target_zone->CanAccessObject(secobj)) {
|
||||||
|
finishedLogZones.insert(target_zone);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* don't relay messages to disconnected endpoints */
|
||||||
|
if (!endpoint->IsConnected())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
finishedLogZones.insert(target_zone);
|
||||||
|
|
||||||
/* don't relay the message to the zone through more than one endpoint */
|
/* don't relay the message to the zone through more than one endpoint */
|
||||||
if (finishedZones.find(target_zone) != finishedZones.end()) {
|
if (finishedZones.find(target_zone) != finishedZones.end()) {
|
||||||
skippedEndpoints.push_back(endpoint);
|
skippedEndpoints.push_back(endpoint);
|
||||||
|
@ -635,15 +648,14 @@ void ApiListener::SyncRelayMessage(const MessageOrigin::Ptr& origin,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* only relay messages to zones which have access to the object */
|
|
||||||
if (!target_zone->CanAccessObject(secobj))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
finishedZones.insert(target_zone);
|
finishedZones.insert(target_zone);
|
||||||
|
|
||||||
SyncSendMessage(endpoint, message);
|
SyncSendMessage(endpoint, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (log && allZones.size() != finishedLogZones.size())
|
||||||
|
PersistMessage(message, secobj);
|
||||||
|
|
||||||
BOOST_FOREACH(const Endpoint::Ptr& endpoint, skippedEndpoints)
|
BOOST_FOREACH(const Endpoint::Ptr& endpoint, skippedEndpoints)
|
||||||
endpoint->SetLocalLogPosition(ts);
|
endpoint->SetLocalLogPosition(ts);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue