Skip to content

Commit 47daa71

Browse files
committed
For the same zone, delay sync until icinga::Hello tells remote capabilities
They'll become important for teamwork in a zone.
1 parent 7cc3faa commit 47daa71

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lib/remote/apilistener.cpp

+16-3
Original file line numberDiff line numberDiff line change
@@ -852,11 +852,24 @@ void ApiListener::NewClientHandlerInternal(
852852
JsonRpcConnection::Ptr aclient = new JsonRpcConnection(identity, verify_ok, client, role);
853853

854854
if (endpoint) {
855-
endpoint->AddClient(aclient);
855+
static const auto reuniteCluster ([](const JsonRpcConnection::Ptr& aclient) {
856+
auto endpoint (aclient->GetEndpoint());
856857

857-
Utility::QueueAsyncCallback([this, aclient, endpoint]() {
858-
SyncClient(aclient, endpoint, true);
858+
endpoint->AddClient(aclient);
859+
860+
Utility::QueueAsyncCallback([this, aclient, endpoint] {
861+
SyncClient(aclient, endpoint, true);
862+
});
859863
});
864+
865+
if (endpoint->GetZone() == Zone::GetLocalZone()) {
866+
// Nodes in the same zone, which do teamwork, must know each other's capabilities in advance.
867+
// Hence, we delay everything else until they're told us via an icinga::Hello message.
868+
// Even v2.12 nodes send this message at the beginning, so we're safe.
869+
aclient->OnNextHello.connect(reuniteCluster);
870+
} else {
871+
reuniteCluster(aclient);
872+
}
860873
} else if (!AddAnonymousClient(aclient)) {
861874
Log(LogNotice, "ApiListener")
862875
<< "Ignoring anonymous JSON-RPC connection " << conninfo

0 commit comments

Comments
 (0)