mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Disallow stage deletions during reload
Co-Authored-By: Yonas Habteab <yonas.habteab@icinga.com> Once the new worker process has read the config, it also includes a `include */include.conf` statement within the config packages root directory, and from there on we must not allow to delete any stage directory from the config package. Otherwise, when the worker actually evaluates that include statement, it will fail to find the directory where the include file is located, or the `active.conf` file, which is included from each stage's `include.conf` file, thus causing the worker fail.
This commit is contained in:
parent
78adfe4ce6
commit
abf08d0461
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "remote/configstageshandler.hpp"
|
#include "remote/configstageshandler.hpp"
|
||||||
#include "remote/configpackageutility.hpp"
|
#include "remote/configpackageutility.hpp"
|
||||||
|
#include "remote/configobjectslock.hpp"
|
||||||
#include "remote/httputility.hpp"
|
#include "remote/httputility.hpp"
|
||||||
#include "remote/filterutility.hpp"
|
#include "remote/filterutility.hpp"
|
||||||
#include "base/application.hpp"
|
#include "base/application.hpp"
|
||||||
@ -228,6 +229,13 @@ void ConfigStagesHandler::HandleDelete(
|
|||||||
if (!ConfigPackageUtility::ValidateStageName(stageName))
|
if (!ConfigPackageUtility::ValidateStageName(stageName))
|
||||||
return HttpUtility::SendJsonError(response, params, 400, "Invalid stage name '" + stageName + "'.");
|
return HttpUtility::SendJsonError(response, params, 400, "Invalid stage name '" + stageName + "'.");
|
||||||
|
|
||||||
|
ConfigObjectsSharedLock lock (std::try_to_lock);
|
||||||
|
|
||||||
|
if (!lock) {
|
||||||
|
HttpUtility::SendJsonError(response, params, 503, "Icinga is reloading");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ConfigPackageUtility::DeleteStage(packageName, stageName);
|
ConfigPackageUtility::DeleteStage(packageName, stageName);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user