diff options
author | Simon Rettberg | 2019-09-26 14:11:02 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-09-26 14:11:02 +0200 |
commit | d5f094d1dbd78f870b9ed73d56c5d7acd510a8f2 (patch) | |
tree | baf09f24fd3a7d70d31c7d62b910faf176a6f996 | |
parent | [serversetup-bwlp-ipxe] Add DHCP option overrides; add hook mechanism (diff) | |
download | slx-admin-d5f094d1dbd78f870b9ed73d56c5d7acd510a8f2.tar.gz slx-admin-d5f094d1dbd78f870b9ed73d56c5d7acd510a8f2.tar.xz slx-admin-d5f094d1dbd78f870b9ed73d56c5d7acd510a8f2.zip |
[dnbd3] Prevent A_I value from increasing all the time
serverid in dnbd3_server would increase a lot on every query of the
servers. Stop that.
-rw-r--r-- | modules-available/dnbd3/inc/dnbd3util.inc.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/modules-available/dnbd3/inc/dnbd3util.inc.php b/modules-available/dnbd3/inc/dnbd3util.inc.php index 35fad8b3..6ede18d5 100644 --- a/modules-available/dnbd3/inc/dnbd3util.inc.php +++ b/modules-available/dnbd3/inc/dnbd3util.inc.php @@ -7,10 +7,18 @@ class Dnbd3Util { $dynClients = RunMode::getForMode('dnbd3', 'proxy', false, true); $satServerIp = Property::getServerIp(); $servers = array(); + $allUuids = []; + $hasSelf = false; $res = Database::simpleQuery('SELECT s.serverid, s.machineuuid, s.fixedip, s.lastup, s.lastdown, m.clientip FROM dnbd3_server s LEFT JOIN machine m USING (machineuuid)'); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + if (!empty($row['machineuuid'])) { + $allUuids[$row['machineuuid']] = true; + } + if ($row['fixedip'] === '<self>') { + $hasSelf = true; + } if (!is_null($row['fixedip'])) { $ip = $row['fixedip']; } elseif (!is_null($row['clientip'])) { @@ -37,6 +45,8 @@ class Dnbd3Util { } // See if any clients are in dnbd3 proxy mode but don't have a matching row in the dnbd3_server table foreach ($dynClients as $client) { + if (isset($allUuids[$client['machineuuid']])) + continue; Database::exec('INSERT IGNORE INTO dnbd3_server (machineuuid) VALUES (:machineuuid)', array('machineuuid' => $client['machineuuid'])); // Missing from $servers now but we'll handle them in the next run, so don't bother @@ -44,7 +54,9 @@ class Dnbd3Util { // Same for this server - we use the special fixedip '<self>' for it and need to make surecx we don't have the // IP address of the server itself in the list. Database::exec('DELETE FROM dnbd3_server WHERE fixedip = :serverip', array('serverip' => $satServerIp)); - Database::exec("INSERT IGNORE INTO dnbd3_server (fixedip) VALUES ('<self>')"); + if (!$hasSelf) { + Database::exec("INSERT IGNORE INTO dnbd3_server (fixedip) VALUES ('<self>')"); + } // Delete orphaned entires with machineuuid from dnbd3_server where we don't have a runmode entry Database::exec('DELETE s FROM dnbd3_server s LEFT JOIN runmode r USING (machineuuid) |