Skip to content

Commit d0657a0

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Do not barf stack trace if stats DB is missing"
2 parents 0e08e9b + 1cdf413 commit d0657a0

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)