Skip to content

Zone#GetEndpoints(): return endpoints in the specified order, not randomly🎲 #10389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/icinga/apiactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/icinga/clusterevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
3 changes: 1 addition & 2 deletions lib/livestatus/zonestable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions lib/remote/zone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -66,7 +65,7 @@ std::set<Endpoint::Ptr> Zone::GetEndpoints() const
if (!endpoint)
continue;

result.insert(endpoint);
result.emplace_back(std::move(endpoint));
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/remote/zone.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Zone final : public ObjectImpl<Zone>
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;

Expand Down
Loading