ApiListener: Process cluster config updates sequentially

This commit is contained in:
Yonas Habteab 2024-03-08 10:09:53 +01:00
parent 1a55b68541
commit 433e2de13a
1 changed files with 11 additions and 0 deletions

View File

@ -8,6 +8,7 @@
#include "base/json.hpp"
#include "base/convert.hpp"
#include "config/vmops.hpp"
#include "remote/configobjectslock.hpp"
#include <fstream>
using namespace icinga;
@ -104,6 +105,11 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin
return Empty;
}
// Wait for the object name to become available for processing and block it immediately.
// Doing so guarantees that only one (create/update/delete) cluster event or API request of a
// given object is being processed at any given time.
ObjectNameLock objectNameLock(ptype, objName);
ConfigObject::Ptr object = ctype->GetObject(objName);
String config = params->Get("config");
@ -258,6 +264,11 @@ Value ApiListener::ConfigDeleteObjectAPIHandler(const MessageOrigin::Ptr& origin
return Empty;
}
// Wait for the object name to become available for processing and block it immediately.
// Doing so guarantees that only one (create/update/delete) cluster event or API request of a
// given object is being processed at any given time.
ObjectNameLock objectNameLock(ptype, objName);
ConfigObject::Ptr object = ctype->GetObject(objName);
if (!object) {