Hard code version from our container, predicate renaming

service_subpkg
Tyler Goodlet 2023-03-09 18:33:13 -05:00
parent 15064d94cb
commit 0772b4a0fa
1 changed files with 20 additions and 5 deletions

View File

@ -40,6 +40,9 @@ log = get_logger(__name__)
_config = { _config = {
'port': 19200, 'port': 19200,
'log_level': 'debug', 'log_level': 'debug',
# hardcoded to our image version
'version': '7.17.4',
} }
@ -77,21 +80,31 @@ def start_elasticsearch(
remove=True remove=True
) )
async def start_matcher(msg: str): async def health_query(msg: str | None = None):
if (
msg
and _config['version'] in msg
):
return True
try: try:
health = (await asks.get( health = (await asks.get(
'http://localhost:19200/_cat/health', 'http://localhost:19200/_cat/health',
params={'format': 'json'} params={'format': 'json'}
)).json() )).json()
kog.info(
'ElasticSearch cntr health:\n'
f'{health}'
)
except OSError: except OSError:
log.error('couldnt reach elastic container') log.exception('couldnt reach elastic container')
return False return False
log.info(health) log.info(health)
return health[0]['status'] == 'green' return health[0]['status'] == 'green'
async def stop_matcher(msg: str): async def chk_for_closed_msg(msg: str):
return msg == 'closed' return msg == 'closed'
return ( return (
@ -106,8 +119,10 @@ def start_elasticsearch(
'startup_query_period': 0.1, 'startup_query_period': 0.1,
'log_msg_key': 'message', 'log_msg_key': 'message',
# 'started_afunc': health_query,
}, },
# expected startup and stop msgs # expected startup and stop msgs
start_matcher, health_query,
stop_matcher, chk_for_closed_msg,
) )