[feat] Also run query against mysql to ensure queries can complete

This commit is contained in:
William Wernert
2020-11-10 11:02:34 -05:00
parent b3c527e7a9
commit 7f218e5297

View File

@@ -24,12 +24,14 @@ def mysql_conn(retry):
for i in range(0, retry): for i in range(0, retry):
log.debug(f'Connection attempt {i+1}') log.debug(f'Connection attempt {i+1}')
try: try:
_mysql.connect( db = _mysql.connect(
host=mainip, host=mainip,
user='root', user='root',
passwd=__salt__['pillar.get']('secrets:mysql') passwd=__salt__['pillar.get']('secrets:mysql')
) )
log.debug(f'Connected to MySQL server on {mainip} after {retry} attempts.') log.debug(f'Connected to MySQL server on {mainip} after {i} attempts.')
db.query("""SELECT 1;""")
log.debug(f'Successfully completed query against MySQL server on {mainip}')
mysql_up = True mysql_up = True
break break
except _mysql.OperationalError as e: except _mysql.OperationalError as e: