From 44d0c9013b4ac5298fbd69475af9807faa2bcad1 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 28 Sep 2018 13:55:41 +0200 Subject: [PATCH] Ignore synced config zones where no config item exists The culprit is that we're in compiling configuration stage here, we don't have access to `Zone::GetByName()` as objects have not been activated yet. Our best guess is from a config item loaded before (e.g. from zones.conf) since no-one can sync zones via cluster config sync either. It may not be 100% correct since the zone object itself may be invalid. Still, if the zone object validator fails later, the config breaks either way. The problem with removal of these directories is dealt by the cluster config sync with stages. refs #6727 refs #6716 --- lib/cli/daemonutility.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/cli/daemonutility.cpp b/lib/cli/daemonutility.cpp index ba1c24d9a..b586544ee 100644 --- a/lib/cli/daemonutility.cpp +++ b/lib/cli/daemonutility.cpp @@ -31,6 +31,15 @@ static void IncludeZoneDirRecursive(const String& path, const String& package, b { String zoneName = Utility::BaseName(path); + /* We don't have an activated zone object yet. We may forcefully guess from configitems + * to not include this specific synced zones directory. + */ + if(!ConfigItem::GetByTypeAndName(Type::GetByName("Zone"), zoneName)) { + Log(LogWarning, "config") + << "Ignoring directory '" << path << "' for unknown zone '" << zoneName << "'."; + return; + } + /* register this zone path for cluster config sync */ ConfigCompiler::RegisterZoneDir("_etc", path, zoneName); @@ -48,6 +57,15 @@ static void IncludeNonLocalZone(const String& zonePath, const String& package, b String zoneName = Utility::BaseName(zonePath); + /* We don't have an activated zone object yet. We may forcefully guess from configitems + * to not include this specific synced zones directory. + */ + if(!ConfigItem::GetByTypeAndName(Type::GetByName("Zone"), zoneName)) { + Log(LogWarning, "config") + << "Ignoring directory '" << zonePath << "' for unknown zone '" << zoneName << "'."; + return; + } + /* Check whether this node already has an authoritative config version * from zones.d in etc or api package directory, or a local marker file) */ -- 2.40.0