Skip to content

Commit 6b8a018

Browse files
authored
Merge pull request #8486 from Icinga/bugfix/config-sync-only-remove-files-if-timestamp-changed
Config sync: Only remove files, if timestamp changed
2 parents 6749b9a + f184c1b commit 6b8a018

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/remote/apilistener-filesync.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic
421421
Dictionary::Ptr productionConfig = MergeConfigUpdate(productionConfigInfo);
422422
Dictionary::Ptr newConfig = MergeConfigUpdate(newConfigInfo);
423423

424+
bool timestampChanged = false;
425+
426+
if (CompareTimestampsConfigChange(productionConfig, newConfig, stageConfigZoneDir)) {
427+
timestampChanged = true;
428+
}
429+
424430
/* If we have received 'checksums' via cluster message, go for it.
425431
* Otherwise do the old timestamp dance for versions < 2.11.
426432
*/
@@ -429,7 +435,7 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic
429435
<< "Received configuration for zone '" << zoneName << "' from endpoint '"
430436
<< fromEndpointName << "'. Comparing the timestamp and checksums.";
431437

432-
if (CompareTimestampsConfigChange(productionConfig, newConfig, stageConfigZoneDir)) {
438+
if (timestampChanged) {
433439

434440
if (CheckConfigChange(productionConfigInfo, newConfigInfo))
435441
configChange = true;
@@ -446,7 +452,7 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic
446452
<< "Received configuration update without checksums from parent endpoint "
447453
<< fromEndpointName << ". This behaviour is deprecated. Please upgrade the parent endpoint to 2.11+";
448454

449-
if (CompareTimestampsConfigChange(productionConfig, newConfig, stageConfigZoneDir)) {
455+
if (timestampChanged) {
450456
configChange = true;
451457
}
452458

@@ -508,8 +514,8 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic
508514
<< "Applying configuration file update for path '" << stageConfigZoneDir << "' ("
509515
<< numBytes << " Bytes).";
510516

511-
// If the update removes a path, delete it on disk and signal a config change.
512-
{
517+
if (timestampChanged) {
518+
// If the update removes a path, delete it on disk and signal a config change.
513519
ObjectLock xlock(productionConfig);
514520

515521
for (const Dictionary::Pair& kv : productionConfig) {

0 commit comments

Comments
 (0)