Skip to content

Commit 1cdf413

Browse files
committed
Do not barf stack trace if stats DB is missing
This can happen if devstack fails to run, but we still run the post tasks. Also could happen if some sort of hybrid job configuration does not run all of devstack but we still end up running post jobs. Just warn to stderr and assume no DB info. Change-Id: I211a331ab668dbb0ad7882908cca4363f865d924
1 parent 50e3c06 commit 1cdf413

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

tools/get-stats.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,17 @@ def proc_matches(proc):
8686

8787
def get_db_stats(host, user, passwd):
8888
dbs = []
89-
db = pymysql.connect(host=host, user=user, password=passwd,
90-
database='stats',
91-
cursorclass=pymysql.cursors.DictCursor)
89+
try:
90+
db = pymysql.connect(host=host, user=user, password=passwd,
91+
database='stats',
92+
cursorclass=pymysql.cursors.DictCursor)
93+
except pymysql.err.OperationalError as e:
94+
if 'Unknown database' in str(e):
95+
print('No stats database; assuming devstack failed',
96+
file=sys.stderr)
97+
return []
98+
raise
99+
92100
with db:
93101
with db.cursor() as cur:
94102
cur.execute('SELECT db,op,count FROM queries')

0 commit comments

Comments
 (0)