Clean up Ceph pipeline and add more debug logs

This commit is contained in:
Joshua Boniface 2019-06-18 11:19:03 -04:00
parent 46a416bc78
commit 5a327dc41a
1 changed files with 14 additions and 5 deletions

View File

@ -791,12 +791,9 @@ if enable_storage:
@zk_conn.DataWatch('/ceph/cmd') @zk_conn.DataWatch('/ceph/cmd')
def cmd(data, stat, event=''): def cmd(data, stat, event=''):
if data: if data:
data = data.decode('ascii') CephInstance.run_command(zk_conn, data.decode('ascii'), d_osd)
else: else:
data = '' logger.out('Invalid data in Ceph command pipeline', state='e')
if data:
CephInstance.run_command(zk_conn, data, d_osd)
# OSD objects # OSD objects
@zk_conn.ChildrenWatch('/ceph/osds') @zk_conn.ChildrenWatch('/ceph/osds')
@ -928,6 +925,8 @@ def update_zookeeper():
osd_dump = dict() osd_dump = dict()
retcode, stdout, stderr = common.run_os_command('ceph osd dump --format json') retcode, stdout, stderr = common.run_os_command('ceph osd dump --format json')
osd_dump_raw = json.loads(stdout)['osds'] osd_dump_raw = json.loads(stdout)['osds']
if debug:
print("Loop through OSD dump")
for osd in osd_dump_raw: for osd in osd_dump_raw:
osd_dump.update({ osd_dump.update({
str(osd['osd']): { str(osd['osd']): {
@ -938,9 +937,13 @@ def update_zookeeper():
} }
}) })
# Parse the df data # Parse the df data
if debug:
print("Parse the OSD df data")
osd_df = dict() osd_df = dict()
retcode, stdout, stderr = common.run_os_command('ceph osd df --format json') retcode, stdout, stderr = common.run_os_command('ceph osd df --format json')
osd_df_raw = json.loads(stdout)['nodes'] osd_df_raw = json.loads(stdout)['nodes']
if debug:
print("Loop through OSD df")
for osd in osd_df_raw: for osd in osd_df_raw:
osd_df.update({ osd_df.update({
str(osd['id']): { str(osd['id']): {
@ -953,8 +956,12 @@ def update_zookeeper():
} }
}) })
# Parse the status data # Parse the status data
if debug:
print("Parse the OSD status data")
osd_status = dict() osd_status = dict()
retcode, stdout, stderr = common.run_os_command('ceph osd status') retcode, stdout, stderr = common.run_os_command('ceph osd status')
if debug:
print("Loop through OSD status data")
for line in stderr.split('\n'): for line in stderr.split('\n'):
# Strip off colour # Strip off colour
line = re.sub(r'\x1b(\[.*?[@-~]|\].*?(\x07|\x1b\\))', '', line) line = re.sub(r'\x1b(\[.*?[@-~]|\].*?(\x07|\x1b\\))', '', line)
@ -984,6 +991,8 @@ def update_zookeeper():
} }
}) })
# Merge them together into a single meaningful dict # Merge them together into a single meaningful dict
if debug:
print("Merge OSD data together")
osd_stats = dict() osd_stats = dict()
for osd in osd_list: for osd in osd_list:
this_dump = osd_dump[osd] this_dump = osd_dump[osd]