mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
Zone#GetEndpoints(): return endpoints in the specified order, not randomly
ApiListener#RelayMessageOne() relays every given message to the first connected endpoint Zone#GetEndpoints() returns. Randomness in combination with bad luck can direct more traffic (from a particular network segment) to one master than the admin wants. This change lets the Zone#endpoints order prefer one endpoint over the other.
This commit is contained in:
parent
5e902fe4a7
commit
a943c4588b
@ -932,7 +932,7 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object, cons
|
||||
for (const Zone::Ptr& zone : ConfigType::GetObjectsByType<Zone>()) {
|
||||
/* Fetch immediate child zone members */
|
||||
if (zone->GetParent() == localZone && zone->CanAccessObject(endpointPtr->GetZone())) {
|
||||
std::set<Endpoint::Ptr> endpoints = zone->GetEndpoints();
|
||||
auto endpoints (zone->GetEndpoints());
|
||||
|
||||
for (const Endpoint::Ptr& childEndpoint : endpoints) {
|
||||
if (!(childEndpoint->GetCapabilities() & (uint_fast64_t)ApiCapabilities::ExecuteArbitraryCommand)) {
|
||||
|
@ -966,7 +966,7 @@ Value ClusterEvents::ExecuteCommandAPIHandler(const MessageOrigin::Ptr& origin,
|
||||
for (const Zone::Ptr &zone : ConfigType::GetObjectsByType<Zone>()) {
|
||||
/* Fetch immediate child zone members */
|
||||
if (zone->GetParent() == localZone && zone->CanAccessObject(endpointZone)) {
|
||||
std::set<Endpoint::Ptr> endpoints = zone->GetEndpoints();
|
||||
auto endpoints (zone->GetEndpoints());
|
||||
|
||||
for (const Endpoint::Ptr &childEndpoint : endpoints) {
|
||||
if (!(childEndpoint->GetCapabilities() & (uint_fast64_t)ApiCapabilities::ExecuteArbitraryCommand)) {
|
||||
|
@ -70,8 +70,7 @@ Value ZonesTable::EndpointsAccessor(const Value& row)
|
||||
if (!zone)
|
||||
return Empty;
|
||||
|
||||
std::set<Endpoint::Ptr> endpoints = zone->GetEndpoints();
|
||||
|
||||
auto endpoints (zone->GetEndpoints());
|
||||
ArrayData result;
|
||||
|
||||
for (const Endpoint::Ptr& endpoint : endpoints) {
|
||||
|
@ -51,10 +51,9 @@ Zone::Ptr Zone::GetParent() const
|
||||
return m_Parent;
|
||||
}
|
||||
|
||||
std::set<Endpoint::Ptr> Zone::GetEndpoints() const
|
||||
std::vector<Endpoint::Ptr> Zone::GetEndpoints() const
|
||||
{
|
||||
std::set<Endpoint::Ptr> result;
|
||||
|
||||
std::vector<Endpoint::Ptr> result;
|
||||
Array::Ptr endpoints = GetEndpointsRaw();
|
||||
|
||||
if (endpoints) {
|
||||
@ -66,7 +65,7 @@ std::set<Endpoint::Ptr> Zone::GetEndpoints() const
|
||||
if (!endpoint)
|
||||
continue;
|
||||
|
||||
result.insert(endpoint);
|
||||
result.emplace_back(std::move(endpoint));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
void OnAllConfigLoaded() override;
|
||||
|
||||
Zone::Ptr GetParent() const;
|
||||
std::set<Endpoint::Ptr> GetEndpoints() const;
|
||||
std::vector<Endpoint::Ptr> GetEndpoints() const;
|
||||
std::vector<Zone::Ptr> GetAllParentsRaw() const;
|
||||
Array::Ptr GetAllParents() const override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user