mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-31 01:24:19 +02:00
ApiListener: Process cluster config updates sequentially
This commit is contained in:
parent
40011b0584
commit
456144c1dc
@ -7,6 +7,7 @@
|
|||||||
#include "base/configtype.hpp"
|
#include "base/configtype.hpp"
|
||||||
#include "base/json.hpp"
|
#include "base/json.hpp"
|
||||||
#include "base/convert.hpp"
|
#include "base/convert.hpp"
|
||||||
|
#include "base/defer.hpp"
|
||||||
#include "config/vmops.hpp"
|
#include "config/vmops.hpp"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
@ -104,6 +105,15 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin
|
|||||||
return Empty;
|
return Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait for the object name to become available for processing and block it immediately.
|
||||||
|
// Doing so guarantees that only one cluster event (create/update/delete) of a given
|
||||||
|
// object is being processed at any given time.
|
||||||
|
listener->m_ObjectConfigChangeLock.Lock(ptype, objName);
|
||||||
|
|
||||||
|
Defer unlockAndNotify([&listener, &ptype, &objName]{
|
||||||
|
listener->m_ObjectConfigChangeLock.Unlock(ptype, objName);
|
||||||
|
});
|
||||||
|
|
||||||
ConfigObject::Ptr object = ctype->GetObject(objName);
|
ConfigObject::Ptr object = ctype->GetObject(objName);
|
||||||
|
|
||||||
String config = params->Get("config");
|
String config = params->Get("config");
|
||||||
@ -258,6 +268,15 @@ Value ApiListener::ConfigDeleteObjectAPIHandler(const MessageOrigin::Ptr& origin
|
|||||||
return Empty;
|
return Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait for the object name to become available for processing and block it immediately.
|
||||||
|
// Doing so guarantees that only one cluster event (create/update/delete) of a given
|
||||||
|
// object is being processed at any given time.
|
||||||
|
listener->m_ObjectConfigChangeLock.Lock(ptype, objName);
|
||||||
|
|
||||||
|
Defer unlockAndNotify([&listener, &ptype, &objName]{
|
||||||
|
listener->m_ObjectConfigChangeLock.Unlock(ptype, objName);
|
||||||
|
});
|
||||||
|
|
||||||
ConfigObject::Ptr object = ctype->GetObject(objName);
|
ConfigObject::Ptr object = ctype->GetObject(objName);
|
||||||
|
|
||||||
if (!object) {
|
if (!object) {
|
||||||
|
@ -277,6 +277,9 @@ private:
|
|||||||
mutable std::mutex m_ActivePackageStagesLock;
|
mutable std::mutex m_ActivePackageStagesLock;
|
||||||
std::map<String, String> m_ActivePackageStages;
|
std::map<String, String> m_ActivePackageStages;
|
||||||
|
|
||||||
|
/* ensures that at most one create/update/delete is being processed per object at each time */
|
||||||
|
mutable ObjectNameMutex m_ObjectConfigChangeLock;
|
||||||
|
|
||||||
void UpdateActivePackageStagesCache();
|
void UpdateActivePackageStagesCache();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user