Icinga / icingaweb2-module-x509

Keeps track of certificates as they are deployed in a network environment.
https://icinga.com/docs/x509/latest/
GNU General Public License v2.0
107 stars 24 forks source link

Make use of the new `RetryConnection` class #207

Open yhabteab opened 1 year ago

yhabteab commented 1 year ago

Describe the bug

If the database is restarted while the daemon is running, then it may sometimes fail with such an error, which can be fixed by reconnecting to the database:

Cannot connect to server: Connection to tls://[192.168.5.18]:443 failed: No route to host (EHOSTUNREACH)
Cannot connect to server: Connection to tls://[185.233.189.126]:5665 timed out after 5 seconds (ETIMEDOUT)
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
#0 /usr/local/src/ipl-sql/src/Connection.php(401): PDO->prepare('UPDATE x509_tar...')
#1 /usr/local/src/ipl-sql/src/Connection.php(466): ipl\Sql\Connection->prepexec('UPDATE x509_tar...')
#2 /usr/share/icingaweb2-modules/x509/library/X509/Job.php(523): ipl\Sql\Connection->update('x509_target', Array, Array)
#3 /usr/share/icinga-php/vendor/vendor/react/promise/src/RejectedPromise.php(28): Icinga\Module\X509\Job->Icinga\Module\X509\{closure}(Object(RuntimeException))
#4 /usr/share/icinga-php/vendor/vendor/react/promise/src/Promise.php(134): React\Promise\RejectedPromise->then(Object(Closure), Object(Closure))
#5 /usr/share/icinga-php/vendor/vendor/react/promise/src/Promise.php(168): React\Promise\Promise::React\Promise\{closure}(Object(React\Promise\RejectedPromise))
#6 /usr/share/icinga-php/vendor/vendor/react/promise/src/Promise.php(148): React\Promise\Promise->settle(Object(React\Promise\RejectedPromise))
#7 /usr/share/icinga-php/vendor/vendor/react/promise/src/Promise.php(237): React\Promise\Promise->reject(Object(RuntimeException))
#8 /usr/share/icinga-php/vendor/vendor/react/socket/src/TimeoutConnector.php(53): React\Promise\Promise::React\Promise\{closure}(Object(RuntimeException))
#9 /usr/share/icinga-php/vendor/vendor/react/event-loop/src/ExtEvLoop.php(144): React\Socket\TimeoutConnector->React\Socket\{closure}(Object(React\EventLoop\Timer\Timer))
#10 [internal function]: React\EventLoop\ExtEvLoop->React\EventLoop\{closure}()
#11 /usr/share/icinga-php/vendor/vendor/react/event-loop/src/ExtEvLoop.php(208): EvLoop->run(2)
#12 /usr/share/icinga-php/vendor/vendor/react/event-loop/src/Loop.php(55): React\EventLoop\ExtEvLoop->run()
#13 [internal function]: React\EventLoop\Loop::React\EventLoop\{closure}()
#14 {main}

Once the RetryConnection class from ipl-sql is ready, we should use it here.