Merge pull request #8500 from Icinga/bugfix/config-sync-only-remove-files-if-timestamp-changed

Config sync: Only remove files, if timestamp changed
This commit is contained in:
Julian Brost 2020-11-24 16:34:12 +01:00 committed by GitHub
commit da407660f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -421,6 +421,12 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic
Dictionary::Ptr productionConfig = MergeConfigUpdate(productionConfigInfo);
Dictionary::Ptr newConfig = MergeConfigUpdate(newConfigInfo);
bool timestampChanged = false;
if (CompareTimestampsConfigChange(productionConfig, newConfig, stageConfigZoneDir)) {
timestampChanged = true;
}
/* If we have received 'checksums' via cluster message, go for it.
* Otherwise do the old timestamp dance for versions < 2.11.
*/
@ -429,7 +435,7 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic
<< "Received configuration for zone '" << zoneName << "' from endpoint '"
<< fromEndpointName << "'. Comparing the timestamp and checksums.";
if (CompareTimestampsConfigChange(productionConfig, newConfig, stageConfigZoneDir)) {
if (timestampChanged) {
if (CheckConfigChange(productionConfigInfo, newConfigInfo))
configChange = true;
@ -446,7 +452,7 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic
<< "Received configuration update without checksums from parent endpoint "
<< fromEndpointName << ". This behaviour is deprecated. Please upgrade the parent endpoint to 2.11+";
if (CompareTimestampsConfigChange(productionConfig, newConfig, stageConfigZoneDir)) {
if (timestampChanged) {
configChange = true;
}
@ -508,8 +514,8 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic
<< "Applying configuration file update for path '" << stageConfigZoneDir << "' ("
<< numBytes << " Bytes).";
if (timestampChanged) {
// If the update removes a path, delete it on disk and signal a config change.
{
ObjectLock xlock(productionConfig);
for (const Dictionary::Pair& kv : productionConfig) {