From 8788d8a69a796883a28be9baf5febcf0f0a9a623 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Sun, 30 Jun 2024 11:30:58 -0400 Subject: [PATCH] Fixing #5754 and #5759 - Installer Issues -issue#5754: Installer replication loop for. Plugin realms -issue#5759: Remote poller attempts to sync with other pollers during install --- CHANGELOG | 2 ++ install/background.php | 24 +++++++++++++++++++++++- install/functions.php | 5 ++++- lib/installer.php | 8 ++++---- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 91cabcd148..e82e18a972 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ Cacti CHANGELOG 1.2.28 +-issue#5754: Installer replication loop for. Plugin realms +-issue#5759: Remote poller attempts to sync with other pollers during install -issue#5768: Cacti does not properly escape Data Query indexes that include a space -issue#5772: Login log message unification - add client IP address -issue#5773: Update rrd.php missing variable $okpos diff --git a/install/background.php b/install/background.php index e654ef83f8..fc560d6f71 100644 --- a/install/background.php +++ b/install/background.php @@ -46,10 +46,32 @@ global $cli_install; $cli_install = true; +$now = time(); if (cacti_sizeof($params) == 0) { log_install_always('','no parameters passed' . PHP_EOL); - exit(); + exit(0); +} + +if (function_exists('register_process_start')) { + if (!register_process_start('install', 'master', '0', 600)) { + exit(0); + } +} else { + $running = read_config_option('installer_running', true); + + if ($running != '' && $now - $running < 600) { + exit(0); + } + + set_config_option('installer_running', $now); } Installer::beginInstall($params[0]); + +if (function_exists('register_process_start')) { + unregister_process('install', 'master', 0); +} else { + set_config_option('installer_running', ''); +} + diff --git a/install/functions.php b/install/functions.php index 435d0e8a7d..db01d06df1 100644 --- a/install/functions.php +++ b/install/functions.php @@ -1124,7 +1124,7 @@ function install_full_sync() { $skipped = array(); $timeout = array(); - $pollers = db_fetch_assoc('SELECT id, status, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_update) as gap + $pollers = db_fetch_assoc('SELECT id, status, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_update) AS gap FROM poller WHERE id > 1 AND disabled = ""'); @@ -1135,6 +1135,8 @@ function install_full_sync() { log_install_debug('sync', 'Poller ' . $poller['id'] . ' has a status of ' . $poller['status'] . ' with gap ' . $poller['gap']); if (($poller['status'] == POLLER_STATUS_NEW) || ($poller['status'] == POLLER_STATUS_DOWN) || + ($poller['status'] == POLLER_STATUS_HEARTBEAT) || + ($poller['status'] == POLLER_STATUS_RECOVERING) || ($poller['status'] == POLLER_STATUS_DISABLED)) { $skipped[] = $poller['id']; } elseif ($poller['gap'] < $gap_time) { @@ -1156,6 +1158,7 @@ function install_full_sync() { } } } + log_install_debug('sync', 'Success: ' . cacti_sizeof($success) . ', Failed: ' . cacti_sizeof($failed) . ', Skipped: ' . cacti_sizeof($skipped) . ', Total: ' . cacti_sizeof($pollers)); return array( diff --git a/lib/installer.php b/lib/installer.php index 6ce7e9201e..c7b3c65426 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -3616,10 +3616,10 @@ private static function fullSyncDataCollectors() { if ($status['total'] == 0) { log_install_always('sync', __('No Remote Data Collectors found for full synchronization')); } else { - Installer::fullSyncDataCollectorLog($status['timeout'], 'Remote Data Collector with name \'%s\' and id %d previous timed out. Please manually Sync when once online to complete upgrade.'); - Installer::fullSyncDataCollectorLog($status['skipped'], 'Remote Data Collector with name \'%s\' and id %d is not available to sync. Please manually Sync when once online to complete upgrade.'); - Installer::fullSyncDataCollectorLog($status['failed'], 'Remote Data Collector with name \'%s\' and id %d failed Full Sync. Please manually Sync when once online to complete upgrade.'); - Installer::fullSyncDataCollectorLog($status['success'], 'Remote Data Collector with name \'%s\' and id %d completed Full Sync.'); + Installer::fullSyncDataCollectorLog($status['timeout'], "Remote Data Collector with name '%s' and id %d previous timed out. Please manually Sync when once online to complete upgrade."); + Installer::fullSyncDataCollectorLog($status['skipped'], "Remote Data Collector with name '%s' and id %d is not available to sync. Please manually Sync when once online to complete upgrade."); + Installer::fullSyncDataCollectorLog($status['failed'], "Remote Data Collector with name '%s' and id %d failed Full Sync. Please manually Sync when once online to complete upgrade."); + Installer::fullSyncDataCollectorLog($status['success'], "Remote Data Collector with name '%s' and id %d completed Full Sync."); } }