mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 22:24:44 +02:00
Ensure that config sync updates are always sent on reconnect
fixes #11083
This commit is contained in:
parent
b58ddfb158
commit
a7142252fa
@ -333,11 +333,6 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
|
|||||||
<< "New client connection (no client certificate)";
|
<< "New client connection (no client certificate)";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool need_sync = false;
|
|
||||||
|
|
||||||
if (endpoint)
|
|
||||||
need_sync = !endpoint->GetConnected();
|
|
||||||
|
|
||||||
ClientType ctype;
|
ClientType ctype;
|
||||||
|
|
||||||
if (role == RoleClient) {
|
if (role == RoleClient) {
|
||||||
@ -371,10 +366,11 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
|
|||||||
aclient->Start();
|
aclient->Start();
|
||||||
|
|
||||||
if (endpoint) {
|
if (endpoint) {
|
||||||
|
bool needSync = !endpoint->GetConnected();
|
||||||
|
|
||||||
endpoint->AddClient(aclient);
|
endpoint->AddClient(aclient);
|
||||||
|
|
||||||
if (need_sync)
|
m_SyncQueue.Enqueue(boost::bind(&ApiListener::SyncClient, this, aclient, endpoint, needSync));
|
||||||
m_SyncQueue.Enqueue(boost::bind(&ApiListener::SyncClient, this, aclient, endpoint));
|
|
||||||
} else
|
} else
|
||||||
AddAnonymousClient(aclient);
|
AddAnonymousClient(aclient);
|
||||||
} else {
|
} else {
|
||||||
@ -386,7 +382,7 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint)
|
void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint, bool needSync)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
{
|
{
|
||||||
@ -395,8 +391,12 @@ void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoi
|
|||||||
endpoint->SetSyncing(true);
|
endpoint->SetSyncing(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure that the config updates are synced
|
||||||
|
* before the logs are replayed.
|
||||||
|
*/
|
||||||
|
|
||||||
Log(LogInformation, "ApiListener")
|
Log(LogInformation, "ApiListener")
|
||||||
<< "Sending updates for endpoint '" << endpoint->GetName() << "'.";
|
<< "Sending config updates for endpoint '" << endpoint->GetName() << "'.";
|
||||||
|
|
||||||
/* sync zone file config */
|
/* sync zone file config */
|
||||||
SendConfigUpdate(aclient);
|
SendConfigUpdate(aclient);
|
||||||
@ -404,9 +404,19 @@ void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoi
|
|||||||
SendRuntimeConfigObjects(aclient);
|
SendRuntimeConfigObjects(aclient);
|
||||||
|
|
||||||
Log(LogInformation, "ApiListener")
|
Log(LogInformation, "ApiListener")
|
||||||
<< "Finished sending updates for endpoint '" << endpoint->GetName() << "'.";
|
<< "Finished sending config updates for endpoint '" << endpoint->GetName() << "'.";
|
||||||
|
|
||||||
|
if (!needSync)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Log(LogInformation, "ApiListener")
|
||||||
|
<< "Sending replay log for endpoint '" << endpoint->GetName() << "'.";
|
||||||
|
|
||||||
ReplayLog(aclient);
|
ReplayLog(aclient);
|
||||||
|
|
||||||
|
Log(LogInformation, "ApiListener")
|
||||||
|
<< "Finished sending replay log for endpoint '" << endpoint->GetName() << "'.";
|
||||||
|
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
Log(LogCritical, "ApiListener")
|
Log(LogCritical, "ApiListener")
|
||||||
<< "Error while syncing endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex);
|
<< "Error while syncing endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex);
|
||||||
|
@ -156,7 +156,7 @@ private:
|
|||||||
const JsonRpcConnection::Ptr& client = JsonRpcConnection::Ptr());
|
const JsonRpcConnection::Ptr& client = JsonRpcConnection::Ptr());
|
||||||
void SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient);
|
void SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient);
|
||||||
|
|
||||||
void SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint);
|
void SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint, bool needSync);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user