From e3c289ff81e9e84ea54319be92f8ae56d0687164 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 12 Feb 2024 13:34:56 +0100 Subject: [PATCH] ApiListener: Sync runtime configs in order 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. --- lib/remote/apilistener-configsync.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/remote/apilistener-configsync.cpp b/lib/remote/apilistener-configsync.cpp index a12db0bca73..253eddc5371 100644 --- a/lib/remote/apilistener-configsync.cpp +++ b/lib/remote/apilistener-configsync.cpp @@ -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 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(type.get()); if (!dtype)