Skip to content

Commit

Permalink
ApiListener: Sync runtime configs in order
Browse files Browse the repository at this point in the history
Sync all objects in priority descending order, otherwise downtimes,
comments etc. might be synced before their respective checkables, which
would result in comments/downtimes being ignored by the other endpoint
since it doesn't yet know about their checkables. Since the runtime
config updates event doesn't trigger a reload on the remote endpoint,
theses objects won't be synced again til the next reload.
  • Loading branch information
yhabteab committed Feb 12, 2024
1 parent 3c639c6 commit e3c289f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/remote/apilistener-configsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,16 @@ void ApiListener::SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient
Log(LogInformation, "ApiListener")
<< "Syncing runtime objects to endpoint '" << endpoint->GetName() << "'.";

for (const Type::Ptr& type : Type::GetAllTypes()) {
// Sync all objects in priority descending order, otherwise downtimes, comments... might be synced before their
// respective checkables are synchronized, which would result in comments/downtimes being ignored by the other
// endpoint since it does not yet know about their checkables. Since the runtime config updates event doesn't
// trigger a reload on the remote endpoint, these objects won't be synced again til the next reload.
std::vector<Type::Ptr> types = Type::GetAllTypes();
std::sort(types.begin(), types.end(), [](const Type::Ptr& a, const Type::Ptr& b) {
return a->GetActivationPriority() > b->GetActivationPriority();
});

for (const Type::Ptr& type : types) {
auto *dtype = dynamic_cast<ConfigType *>(type.get());

if (!dtype)
Expand Down

0 comments on commit e3c289f

Please sign in to comment.