mirror of https://github.com/Icinga/icinga2.git
Make sure we don't include zones.d directories for zones which were removed
fixes #8256
This commit is contained in:
parent
c29c11c15b
commit
310278344c
|
@ -90,7 +90,7 @@ static void IncludeNonLocalZone(const String& zonePath)
|
||||||
{
|
{
|
||||||
String etcPath = Application::GetZonesDir() + "/" + Utility::BaseName(zonePath);
|
String etcPath = Application::GetZonesDir() + "/" + Utility::BaseName(zonePath);
|
||||||
|
|
||||||
if (Utility::PathExists(etcPath))
|
if (Utility::PathExists(etcPath) || Utility::PathExists(zonePath + "/.authoritative"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IncludeZoneDirRecursive(zonePath);
|
IncludeZoneDirRecursive(zonePath);
|
||||||
|
|
|
@ -58,7 +58,7 @@ Dictionary::Ptr ApiListener::LoadConfigDir(const String& dir)
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictionary::Ptr& newConfig, const String& configDir)
|
bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictionary::Ptr& newConfig, const String& configDir, bool authoritative)
|
||||||
{
|
{
|
||||||
bool configChange = false;
|
bool configChange = false;
|
||||||
|
|
||||||
|
@ -103,6 +103,14 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio
|
||||||
fp.close();
|
fp.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (authoritative) {
|
||||||
|
String authPath = configDir + "/.authoritative";
|
||||||
|
if (!Utility::PathExists(tsPath)) {
|
||||||
|
std::ofstream fp(tsPath.CStr(), std::ofstream::out | std::ostream::trunc);
|
||||||
|
fp.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return configChange;
|
return configChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +135,7 @@ void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const
|
||||||
Dictionary::Ptr newConfig = LoadConfigDir(newDir);
|
Dictionary::Ptr newConfig = LoadConfigDir(newDir);
|
||||||
Dictionary::Ptr oldConfig = LoadConfigDir(oldDir);
|
Dictionary::Ptr oldConfig = LoadConfigDir(oldDir);
|
||||||
|
|
||||||
UpdateConfigDir(oldConfig, newConfig, oldDir);
|
UpdateConfigDir(oldConfig, newConfig, oldDir, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiListener::SyncZoneDirs(void) const
|
void ApiListener::SyncZoneDirs(void) const
|
||||||
|
@ -239,7 +247,7 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin& origin, const Dictio
|
||||||
Dictionary::Ptr newConfig = kv.second;
|
Dictionary::Ptr newConfig = kv.second;
|
||||||
Dictionary::Ptr oldConfig = LoadConfigDir(oldDir);
|
Dictionary::Ptr oldConfig = LoadConfigDir(oldDir);
|
||||||
|
|
||||||
if (UpdateConfigDir(oldConfig, newConfig, oldDir))
|
if (UpdateConfigDir(oldConfig, newConfig, oldDir, false))
|
||||||
configChange = true;
|
configChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ private:
|
||||||
void ReplayLog(const ApiClient::Ptr& client);
|
void ReplayLog(const ApiClient::Ptr& client);
|
||||||
|
|
||||||
static Dictionary::Ptr LoadConfigDir(const String& dir);
|
static Dictionary::Ptr LoadConfigDir(const String& dir);
|
||||||
static bool UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictionary::Ptr& newConfig, const String& configDir);
|
static bool UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictionary::Ptr& newConfig, const String& configDir, bool authoritative);
|
||||||
|
|
||||||
void SyncZoneDirs(void) const;
|
void SyncZoneDirs(void) const;
|
||||||
void SyncZoneDir(const Zone::Ptr& zone) const;
|
void SyncZoneDir(const Zone::Ptr& zone) const;
|
||||||
|
|
Loading…
Reference in New Issue