Skip to content

Commit

Permalink
Feature/koning/info conn timeout (#226)
Browse files Browse the repository at this point in the history
* Add a timeout check for the merlin info kombu connection test. The redis
server will not comply with the connection_timeout config.

* Update docs.
  • Loading branch information
koning committed Jun 2, 2020
1 parent 564f98a commit 71e13d6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- The broker name can now be amqps (with ssl) or amqp (without ssl).
- The encryption key will now be created when running merlin config.
- The merlin info connection check will now enforce a minute timeout
check for the server connections.

### Fixed
- Added a check for initial running workers when using merlin monitor to
Expand Down
4 changes: 3 additions & 1 deletion docs/source/merlin_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ Information (``merlin info``)
-----------------------------

Information about your merlin and python configuration can be printed out by using the
``info`` command. This is helpful for debugging.
``info`` command. This is helpful for debugging. Included in this command
is a server check which will check for server connections. The connection
check will timeout after 60 seconds.

.. code:: bash
Expand Down
15 changes: 14 additions & 1 deletion merlin/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"""
import pprint
import subprocess
import time
from multiprocessing import Process

from kombu import Connection
from tabulate import tabulate
Expand All @@ -53,11 +55,22 @@ def check_server_access(sconf):
print("-" * 28)

excpts = {}
connect_timeout = 60
for s in servers:
if s in sconf:
try:
conn = Connection(sconf[s])
conn.connect()
conn_check = Process(target=conn.connect)
conn_check.start()
counter = 0
while conn_check.is_alive():
time.sleep(1)
counter += 1
if counter > connect_timeout:
conn_check.kill()
raise Exception(
f"Connection was killed due to timeout ({connect_timeout}s)"
)
conn.release()
print(f"{s} connection: OK")
except Exception as e:
Expand Down

0 comments on commit 71e13d6

Please sign in to comment.