Make Ceph commands time out if needed

This commit is contained in:
Joshua Boniface 2019-07-09 14:35:53 -04:00
parent 19701c66e4
commit 8eeba9bc9b
1 changed files with 5 additions and 5 deletions

View File

@ -898,7 +898,7 @@ def update_zookeeper():
# Get Ceph cluster health (for local printing) # Get Ceph cluster health (for local printing)
if debug: if debug:
print("Get Ceph cluster health (for local printing)") print("Get Ceph cluster health (for local printing)")
retcode, stdout, stderr = common.run_os_command('ceph health') retcode, stdout, stderr = common.run_os_command('ceph --connect-timeout=1 health')
ceph_health = stdout.rstrip() ceph_health = stdout.rstrip()
if 'HEALTH_OK' in ceph_health: if 'HEALTH_OK' in ceph_health:
ceph_health_colour = logger.fmt_green ceph_health_colour = logger.fmt_green
@ -912,7 +912,7 @@ def update_zookeeper():
if debug: if debug:
print("Set ceph health information in zookeeper (primary only)") print("Set ceph health information in zookeeper (primary only)")
# Get status info # Get status info
retcode, stdout, stderr = common.run_os_command('ceph status') retcode, stdout, stderr = common.run_os_command('ceph --connect-timeout=1 status')
ceph_status = stdout ceph_status = stdout
try: try:
zkhandler.writedata(zk_conn, { zkhandler.writedata(zk_conn, {
@ -977,7 +977,7 @@ def update_zookeeper():
print("Get data from Ceph OSDs") print("Get data from Ceph OSDs")
# Parse the dump data # Parse the dump data
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 --connect-timeout=1 osd dump --format json')
osd_dump_raw = json.loads(stdout)['osds'] osd_dump_raw = json.loads(stdout)['osds']
if debug: if debug:
print("Loop through OSD dump") print("Loop through OSD dump")
@ -995,7 +995,7 @@ def update_zookeeper():
if debug: if debug:
print("Parse the OSD df data") 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 --connect-timeout=1 osd df --format json')
try: try:
osd_df_raw = json.loads(stdout)['nodes'] osd_df_raw = json.loads(stdout)['nodes']
except: except:
@ -1018,7 +1018,7 @@ def update_zookeeper():
if debug: if debug:
print("Parse the OSD status data") 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 --connect-timeout=1 osd status')
if debug: if debug:
print("Loop through OSD status data") print("Loop through OSD status data")
for line in stderr.split('\n'): for line in stderr.split('\n'):