From 0a1dad0a8f18fd48da49cde4ce8e1e0db295f5ad Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sun, 26 Jul 2015 17:46:47 +0200 Subject: [PATCH] Fix broken cluster config sync w/ latest api changes Apart from dropping the requirement of adding 'include_zones "etc", "zones.d"' on upgrade to 2.4, we've forgotten to register the local zone directory into the new ZoneFragment tree. This fix adds a new function to register the local zones.d directory. After that the config sync works again. fixes #9735 --- lib/cli/daemonutility.cpp | 3 +++ lib/config/configcompiler.cpp | 16 +++++++++++----- lib/config/configcompiler.hpp | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/cli/daemonutility.cpp b/lib/cli/daemonutility.cpp index 4a1f84dad..ffc680248 100644 --- a/lib/cli/daemonutility.cpp +++ b/lib/cli/daemonutility.cpp @@ -48,6 +48,9 @@ void IncludeZoneDirRecursive(const String& path, bool& success) { String zoneName = Utility::BaseName(path); + /* register this zone path for cluster config sync */ + ConfigCompiler::RegisterZoneDir("_etc", path, zoneName); + std::vector expressions; Utility::GlobRecursive(path, "*.conf", boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName), GlobFile); DictExpression expr(expressions); diff --git a/lib/config/configcompiler.cpp b/lib/config/configcompiler.cpp index 80c8850d9..e9b26fd6b 100644 --- a/lib/config/configcompiler.cpp +++ b/lib/config/configcompiler.cpp @@ -177,10 +177,7 @@ void ConfigCompiler::HandleIncludeZone(const String& tag, const String& path, co else ppath = Utility::DirName(GetPath()) + "/" + path; - ZoneFragment zf; - zf.Tag = tag; - zf.Path = ppath; - m_ZoneDirs[zoneName].push_back(zf); + RegisterZoneDir(tag, ppath, zoneName); Utility::GlobRecursive(ppath, pattern, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName), GlobFile); } @@ -321,5 +318,14 @@ std::vector ConfigCompiler::GetZoneDirs(const String& zone) if (it == m_ZoneDirs.end()) return std::vector(); else - return it->second; + return it->second; +} + +void ConfigCompiler::RegisterZoneDir(const String& tag, const String& ppath, const String& zoneName) +{ + ZoneFragment zf; + zf.Tag = tag; + zf.Path = ppath; + m_ZoneDirs[zoneName].push_back(zf); } + diff --git a/lib/config/configcompiler.hpp b/lib/config/configcompiler.hpp index e4626758b..dad82602e 100644 --- a/lib/config/configcompiler.hpp +++ b/lib/config/configcompiler.hpp @@ -107,6 +107,7 @@ public: void *GetScanner(void) const; static std::vector GetZoneDirs(const String& zone); + static void RegisterZoneDir(const String& tag, const String& ppath, const String& zoneName); private: boost::promise > m_Promise; -- 2.40.0