From: Michael Friedrich Date: Tue, 15 Sep 2015 15:56:34 +0000 (+0200) Subject: Prevent object deletion on shutdown when checking !IsActive() X-Git-Tag: v2.4.0~314 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0fd9d3406b7d722eb31a16cf81a9753c8a50f556;p=icinga2 Prevent object deletion on shutdown when checking !IsActive() This is fairly ugly and sets an extension for the ConfigObjectUtility delete handler to signal the OnActiveChanged handler inside the cluster configsync to send a delete event to the other nodes. refs #9927 --- diff --git a/lib/remote/apilistener-configsync.cpp b/lib/remote/apilistener-configsync.cpp index a0e992971..3a3fed389 100644 --- a/lib/remote/apilistener-configsync.cpp +++ b/lib/remote/apilistener-configsync.cpp @@ -53,7 +53,7 @@ void ApiListener::ConfigUpdateObjectHandler(const ConfigObject::Ptr& object, con if (object->IsActive()) { /* Sync object config */ listener->UpdateConfigObject(object, cookie); - } else { + } else if (!object->IsActive() && object->GetExtension("ConfigObjectDeleted")) { /* Delete object */ listener->DeleteConfigObject(object, cookie); } diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp index e59868a74..77106cc8d 100644 --- a/lib/remote/configobjectutility.cpp +++ b/lib/remote/configobjectutility.cpp @@ -154,6 +154,9 @@ bool ConfigObjectUtility::DeleteObjectHelper(const ConfigObject::Ptr& object, bo ConfigItem::Ptr item = ConfigItem::GetByTypeAndName(type->GetName(), object->GetName()); try { + /* mark this object for cluster delete event */ + object->SetExtension("ConfigObjectDeleted", true); + /* triggers signal for DB IDO and other interfaces */ object->Deactivate(); if (item)