Fix that HA enabled objects are started before config validation has finished

fixes #12460
This commit is contained in:
Michael Friedrich 2016-08-17 09:19:05 +02:00
parent 5c0b3c58bd
commit 87bc291a55
3 changed files with 7 additions and 15 deletions

View File

@ -156,6 +156,11 @@ void ApiListener::Start(bool runtimeCreated)
m_ReconnectTimer->Start(); m_ReconnectTimer->Start();
m_ReconnectTimer->Reschedule(0); m_ReconnectTimer->Reschedule(0);
m_AuthorityTimer = new Timer();
m_AuthorityTimer->OnTimerExpired.connect(boost::bind(&ApiListener::UpdateObjectAuthority));
m_AuthorityTimer->SetInterval(30);
m_AuthorityTimer->Start();
OnMasterChanged(true); OnMasterChanged(true);
} }

View File

@ -116,6 +116,7 @@ private:
std::set<HttpServerConnection::Ptr> m_HttpClients; std::set<HttpServerConnection::Ptr> m_HttpClients;
Timer::Ptr m_Timer; Timer::Ptr m_Timer;
Timer::Ptr m_ReconnectTimer; Timer::Ptr m_ReconnectTimer;
Timer::Ptr m_AuthorityTimer;
Endpoint::Ptr m_LocalEndpoint; Endpoint::Ptr m_LocalEndpoint;
static ApiListener::Ptr m_Instance; static ApiListener::Ptr m_Instance;

View File

@ -21,14 +21,10 @@
#include "remote/apilistener.hpp" #include "remote/apilistener.hpp"
#include "base/configtype.hpp" #include "base/configtype.hpp"
#include "base/utility.hpp" #include "base/utility.hpp"
#include "base/initialize.hpp"
#include "base/timer.hpp"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
using namespace icinga; using namespace icinga;
static Timer::Ptr l_AuthorityTimer;
static bool ObjectNameLessComparer(const ConfigObject::Ptr& a, const ConfigObject::Ptr& b) static bool ObjectNameLessComparer(const ConfigObject::Ptr& a, const ConfigObject::Ptr& b)
{ {
return a->GetName() < b->GetName(); return a->GetName() < b->GetName();
@ -70,7 +66,7 @@ void ApiListener::UpdateObjectAuthority(void)
continue; continue;
BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) { BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) {
if (object->GetHAMode() != HARunOnce) if (!object->IsActive() || object->GetHAMode() != HARunOnce)
continue; continue;
bool authority; bool authority;
@ -84,13 +80,3 @@ void ApiListener::UpdateObjectAuthority(void)
} }
} }
} }
static void StaticInitialize(void)
{
l_AuthorityTimer = new Timer();
l_AuthorityTimer->OnTimerExpired.connect(boost::bind(&ApiListener::UpdateObjectAuthority));
l_AuthorityTimer->SetInterval(30);
l_AuthorityTimer->Start();
}
INITIALIZE_ONCE(StaticInitialize);