Skip to content

Commit 94de327

Browse files
Track deleted runtime objects to avaóid erroneous recreation
1 parent cf699b2 commit 94de327

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

lib/remote/apilistener-configsync.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin
9898
/* update the object */
9999
double objVersion = params->Get("version");
100100

101+
auto deletedRuntimeObjects = listener->GetDeletedRuntimeObjects();
102+
if (deletedRuntimeObjects->Get(objName) >= objVersion) {
103+
Log(LogWarning, "ApiListener")
104+
<< "Ignoring config update for deleted object '" << objName << "' of type '" << objType
105+
<< "' from '" << identity << "' (endpoint: '" << endpoint->GetName() << "', zone: '" << endpointZone->GetName() << "')";
106+
return Empty;
107+
}
108+
deletedRuntimeObjects->Remove(objName);
109+
101110
Type::Ptr ptype = Type::GetByName(objType);
102111
auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
103112

@@ -437,6 +446,8 @@ void ApiListener::DeleteConfigObject(const ConfigObject::Ptr& object, const Mess
437446
if (object->GetPackage() != "_api")
438447
return;
439448

449+
GetDeletedRuntimeObjects()->Set(object->GetName(), object->GetVersion());
450+
440451
/* only send objects to zones which have access to the object */
441452
if (client) {
442453
Zone::Ptr target_zone = client->GetEndpoint()->GetZone();

lib/remote/apilistener.ti

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ class ApiListener : ConfigObject
6363
[no_user_modify] String identity;
6464

6565
[state, no_user_modify] Dictionary::Ptr last_failed_zones_stage_validation;
66+
67+
[state, no_user_modify] Dictionary::Ptr deleted_runtime_objects {
68+
default {{{ return new Dictionary(); }}}
69+
};
6670
};
6771

6872
}

0 commit comments

Comments
 (0)