Skip to content

Commit

Permalink
Ensure that obsolete comment/downtime objects are deleted after activ…
Browse files Browse the repository at this point in the history
…ating objects

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

refs #11890
  • Loading branch information
Michael Friedrich committed Jun 3, 2016
1 parent 0ce4139 commit d4d679e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/cli/daemoncommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 0 additions & 4 deletions lib/cli/daemonutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "config/configcompiler.hpp"
#include "config/configcompilercontext.hpp"
#include "config/configitembuilder.hpp"
#include "remote/configobjectutility.hpp"


using namespace icinga;
Expand Down Expand Up @@ -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;

Expand Down
10 changes: 9 additions & 1 deletion lib/config/configcompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

/**
Expand Down

0 comments on commit d4d679e

Please sign in to comment.