#include "config/configcompiler.hpp"
#include "config/configcompilercontext.hpp"
#include "config/configitembuilder.hpp"
+#include "remote/configobjectutility.hpp"
using namespace icinga;
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;
boost::mutex ConfigItem::m_Mutex;
ConfigItem::TypeMap ConfigItem::m_Items;
ConfigItem::ItemList ConfigItem::m_UnnamedItems;
+ConfigItem::IgnoredItemList ConfigItem::m_IgnoredItems;
REGISTER_SCRIPTFUNCTION(__run_with_activation_context, &ConfigItem::RunWithActivationContext);
m_Expression->Evaluate(frame, &debugHints);
} catch (const std::exception& ex) {
if (m_IgnoreOnError) {
- Log(LogWarning, "ConfigObject")
+ Log(LogNotice, "ConfigObject")
<< "Ignoring config object '" << m_Name << "' of type '" << m_Type << "' due to errors: " << DiagnosticInformation(ex);
+ m_IgnoredItems.push_back(m_DebugInfo.Path);
+
return ConfigObject::Ptr();
}
dobj->Validate(FAConfig, utils);
} catch (ValidationError& ex) {
if (m_IgnoreOnError) {
- Log(LogWarning, "ConfigObject")
+ Log(LogNotice, "ConfigObject")
<< "Ignoring config object '" << m_Name << "' of type '" << m_Type << "' due to errors: " << DiagnosticInformation(ex);
+ m_IgnoredItems.push_back(m_DebugInfo.Path);
+
return ConfigObject::Ptr();
}
dobj->OnConfigLoaded();
} catch (const std::exception& ex) {
if (m_IgnoreOnError) {
- Log(LogWarning, "ConfigObject")
+ Log(LogNotice, "ConfigObject")
<< "Ignoring config object '" << m_Name << "' of type '" << m_Type << "' due to errors: " << DiagnosticInformation(ex);
+ m_IgnoredItems.push_back(m_DebugInfo.Path);
+
return ConfigObject::Ptr();
}
m_Object->OnAllConfigLoaded();
} catch (const std::exception& ex) {
if (m_IgnoreOnError) {
- Log(LogWarning, "ConfigObject")
+ Log(LogNotice, "ConfigObject")
<< "Ignoring config object '" << m_Name << "' of type '" << m_Type << "' due to errors: " << DiagnosticInformation(ex);
Unregister();
+ m_IgnoredItems.push_back(m_DebugInfo.Path);
+
return;
}
return items;
}
+
+void ConfigItem::RemoveIgnoredItems(const String& allowedConfigPath)
+{
+ BOOST_FOREACH(const String& path, m_IgnoredItems) {
+ if (path.Find(allowedConfigPath) == String::NPos)
+ continue;
+
+ Log(LogNotice, "ConfigItem")
+ << "Removing ignored item path '" << path << "'.";
+
+ if (unlink(path.CStr()) < 0) {
+ BOOST_THROW_EXCEPTION(posix_error()
+ << boost::errinfo_api_function("unlink")
+ << boost::errinfo_errno(errno)
+ << boost::errinfo_file_name(path));
+ }
+ }
+
+ m_IgnoredItems.clear();
+}
static std::vector<ConfigItem::Ptr> GetItems(const String& type);
+ static void RemoveIgnoredItems(const String& allowedConfigPath);
+
private:
String m_Type; /**< The object type. */
String m_Name; /**< The name. */
typedef std::vector<ConfigItem::Ptr> ItemList;
static ItemList m_UnnamedItems;
- static ItemList m_CommittedItems;
+
+ typedef std::vector<String> IgnoredItemList;
+ static IgnoredItemList m_IgnoredItems;
static ConfigItem::Ptr GetObjectUnlocked(const String& type,
const String& name);