Skip to content

Commit

Permalink
Fix object resync issues
Browse files Browse the repository at this point in the history
refs #11684
  • Loading branch information
gunnarbeutner authored and Crunsher committed Oct 14, 2016
1 parent 2ef6642 commit 759aba8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
26 changes: 21 additions & 5 deletions lib/remote/apilistener-configsync.cpp
Expand Up @@ -107,7 +107,11 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin

String config = params->Get("config");

bool newObject = false;

if (!object && !config.IsEmpty()) {
newObject = true;

/* object does not exist, create it through the API */
Array::Ptr errors = new Array();

Expand Down Expand Up @@ -136,8 +140,8 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin
if (!object)
return Empty;

/* update object attributes if version was changed */
if (objVersion <= object->GetVersion()) {
/* update object attributes if version was changed or if this is a new object */
if (newObject || objVersion <= object->GetVersion()) {
Log(LogNotice, "ApiListener")
<< "Discarding config update for object '" << object->GetName()
<< "': Object version " << std::fixed << object->GetVersion()
Expand Down Expand Up @@ -337,8 +341,14 @@ void ApiListener::UpdateConfigObject(const ConfigObject::Ptr& object, const Mess

if (client)
JsonRpc::SendMessage(client->GetStream(), message);
else
else {
Zone::Ptr target = static_pointer_cast<Zone>(object->GetZone());

if (!target)
target = Zone::GetLocalZone();

RelayMessage(origin, object, message, false);
}
}


Expand Down Expand Up @@ -379,8 +389,14 @@ void ApiListener::DeleteConfigObject(const ConfigObject::Ptr& object, const Mess

if (client)
JsonRpc::SendMessage(client->GetStream(), message);
else
RelayMessage(origin, object, message, false);
else {
Zone::Ptr target = static_pointer_cast<Zone>(object->GetZone());

if (!target)
target = Zone::GetLocalZone();

RelayMessage(origin, target, message, false);
}
}

/* Initial sync on connect for new endpoints */
Expand Down
6 changes: 6 additions & 0 deletions lib/remote/apilistener.cpp
Expand Up @@ -164,6 +164,12 @@ void ApiListener::Start(bool runtimeCreated)
OnMasterChanged(true);
}

void ApiListener::Stop(bool runtimeDeleted)
{
boost::mutex::scoped_lock lock(m_LogLock);
CloseLogFile();
}

ApiListener::Ptr ApiListener::GetInstance(void)
{
return m_Instance;
Expand Down
1 change: 1 addition & 0 deletions lib/remote/apilistener.hpp
Expand Up @@ -104,6 +104,7 @@ class I2_REMOTE_API ApiListener : public ObjectImpl<ApiListener>
virtual void OnConfigLoaded(void) override;
virtual void OnAllConfigLoaded(void) override;
virtual void Start(bool runtimeCreated) override;
virtual void Stop(bool runtimeDeleted) override;

virtual void ValidateTlsProtocolmin(const String& value, const ValidationUtils& utils) override;

Expand Down

0 comments on commit 759aba8

Please sign in to comment.