[icinga-checkins] icinga.org: icinga2/fix/validation-no-comment-downtime-delete-11890: Ensure that obsolete comment/ downtime objects are deleted after activating objects

git at icinga.org git at icinga.org
Fri Jun 3 14:42:40 CEST 2016


Module: icinga2
Branch: fix/validation-no-comment-downtime-delete-11890
Commit: d4d679e0149eeacb524ea8d1d6af4ece2c9e2781
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=d4d679e0149eeacb524ea8d1d6af4ece2c9e2781

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Fri Jun  3 14:16:52 2016 +0200

Ensure that obsolete comment/downtime objects are deleted after activating objects

Config validation shouldn't be able to purge the files, only on
restart.

refs #11890

---

 lib/cli/daemoncommand.cpp     |    4 ++++
 lib/cli/daemonutility.cpp     |    4 ----
 lib/config/configcompiler.cpp |   10 +++++++++-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/lib/cli/daemoncommand.cpp b/lib/cli/daemoncommand.cpp
index 5d8e6f5..54bdda4 100644
--- a/lib/cli/daemoncommand.cpp
+++ b/lib/cli/daemoncommand.cpp
@@ -20,6 +20,7 @@
 #include "cli/daemoncommand.hpp"
 #include "cli/daemonutility.hpp"
 #include "remote/apilistener.hpp"
+#include "remote/configobjectutility.hpp"
 #include "config/configcompiler.hpp"
 #include "config/configcompilercontext.hpp"
 #include "config/configitembuilder.hpp"
@@ -296,6 +297,9 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
 		Logger::DisableConsoleLog();
 	}
 
+	/* Remove ignored Downtime/Comment objects. */
+	ConfigItem::RemoveIgnoredItems(ConfigObjectUtility::GetConfigDir());
+
 #ifndef _WIN32
 	struct sigaction sa;
 	memset(&sa, 0, sizeof(sa));
diff --git a/lib/cli/daemonutility.cpp b/lib/cli/daemonutility.cpp
index 84470cf..a6fe455 100644
--- a/lib/cli/daemonutility.cpp
+++ b/lib/cli/daemonutility.cpp
@@ -24,7 +24,6 @@
 #include "config/configcompiler.hpp"
 #include "config/configcompilercontext.hpp"
 #include "config/configitembuilder.hpp"
-#include "remote/configobjectutility.hpp"
 
 
 using namespace icinga;
@@ -169,9 +168,6 @@ bool DaemonUtility::LoadConfigFiles(const std::vector<std::string>& configs,
 	WorkQueue upq(25000, Application::GetConcurrency());
 	bool result = ConfigItem::CommitItems(ascope.GetContext(), upq, newItems);
 
-	/* Remove ignored Downtime/Comment objects. */
-	ConfigItem::RemoveIgnoredItems(ConfigObjectUtility::GetConfigDir());
-
 	if (!result)
 		return false;
 
diff --git a/lib/config/configcompiler.cpp b/lib/config/configcompiler.cpp
index 6eb826f..1cbe927 100644
--- a/lib/config/configcompiler.cpp
+++ b/lib/config/configcompiler.cpp
@@ -113,7 +113,15 @@ String ConfigCompiler::GetPackage(void) const
 void ConfigCompiler::CollectIncludes(std::vector<Expression *>& expressions,
     const String& file, const String& zone, const String& package)
 {
-	expressions.push_back(CompileFile(file, zone, package));
+	try {
+		Expression *expr = CompileFile(file, zone, package);
+
+		if (expr)
+			expressions.push_back(expr);
+
+	} catch (const std::exception& ex) {
+		Log(LogNotice, "config", DiagnosticInformation(ex));
+	}
 }
 
 /**



More information about the icinga-checkins mailing list