Add more logging during OSD creation/deletion
This commit is contained in:
parent
3adeef6fdd
commit
1622226c32
|
@ -90,6 +90,7 @@ def add_osd(zk_conn, logger, node, device, weight):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# 3. Create the OSD for real
|
# 3. Create the OSD for real
|
||||||
|
logger.out('Preparing LVM for new OSD disk with ID {} on {}'.format(osd_id, device), state='i')
|
||||||
retcode, stdout, stderr = common.run_os_command(
|
retcode, stdout, stderr = common.run_os_command(
|
||||||
'ceph-volume lvm prepare --bluestore --data {device}'.format(
|
'ceph-volume lvm prepare --bluestore --data {device}'.format(
|
||||||
osdid=osd_id,
|
osdid=osd_id,
|
||||||
|
@ -103,6 +104,7 @@ def add_osd(zk_conn, logger, node, device, weight):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# 4a. Get OSD FSID
|
# 4a. Get OSD FSID
|
||||||
|
logger.out('Getting OSD FSID for ID {} on {}'.format(osd_id, device), state='i')
|
||||||
retcode, stdout, stderr = common.run_os_command(
|
retcode, stdout, stderr = common.run_os_command(
|
||||||
'ceph-volume lvm list {device}'.format(
|
'ceph-volume lvm list {device}'.format(
|
||||||
osdid=osd_id,
|
osdid=osd_id,
|
||||||
|
@ -121,6 +123,7 @@ def add_osd(zk_conn, logger, node, device, weight):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# 4b. Activate the OSD
|
# 4b. Activate the OSD
|
||||||
|
logger.out('Activating new OSD disk with ID {}'.format(osd_id, device), state='i')
|
||||||
retcode, stdout, stderr = common.run_os_command(
|
retcode, stdout, stderr = common.run_os_command(
|
||||||
'ceph-volume lvm activate --bluestore {osdid} {osdfsid}'.format(
|
'ceph-volume lvm activate --bluestore {osdid} {osdfsid}'.format(
|
||||||
osdid=osd_id,
|
osdid=osd_id,
|
||||||
|
@ -134,6 +137,7 @@ def add_osd(zk_conn, logger, node, device, weight):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# 5. Add it to the crush map
|
# 5. Add it to the crush map
|
||||||
|
logger.out('Activating new OSD disk with ID {} to CRUSH map'.format(osd_id), state='i')
|
||||||
retcode, stdout, stderr = common.run_os_command(
|
retcode, stdout, stderr = common.run_os_command(
|
||||||
'ceph osd crush add osd.{osdid} {weight} root=default host={node}'.format(
|
'ceph osd crush add osd.{osdid} {weight} root=default host={node}'.format(
|
||||||
osdid=osd_id,
|
osdid=osd_id,
|
||||||
|
@ -161,6 +165,7 @@ def add_osd(zk_conn, logger, node, device, weight):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# 7. Add the new OSD to the list
|
# 7. Add the new OSD to the list
|
||||||
|
logger.out('Adding new OSD disk with ID {} to Zookeeper'.format(osd_id), state='i')
|
||||||
zkhandler.writedata(zk_conn, {
|
zkhandler.writedata(zk_conn, {
|
||||||
'/ceph/osds/{}'.format(osd_id): '',
|
'/ceph/osds/{}'.format(osd_id): '',
|
||||||
'/ceph/osds/{}/node'.format(osd_id): node,
|
'/ceph/osds/{}/node'.format(osd_id): node,
|
||||||
|
@ -187,6 +192,7 @@ def remove_osd(zk_conn, logger, osd_id, osd_obj):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# 1. Set the OSD out so it will flush
|
# 1. Set the OSD out so it will flush
|
||||||
|
logger.out('Setting out OSD disk with ID {}'.format(osd_id), state='i')
|
||||||
retcode, stdout, stderr = common.run_os_command('ceph osd out {}'.format(osd_id))
|
retcode, stdout, stderr = common.run_os_command('ceph osd out {}'.format(osd_id))
|
||||||
if retcode:
|
if retcode:
|
||||||
print('ceph osd out')
|
print('ceph osd out')
|
||||||
|
@ -195,6 +201,7 @@ def remove_osd(zk_conn, logger, osd_id, osd_obj):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# 2. Wait for the OSD to flush
|
# 2. Wait for the OSD to flush
|
||||||
|
logger.out('Flushing OSD disk with ID {}'.format(osd_id), state='i')
|
||||||
osd_string = str()
|
osd_string = str()
|
||||||
while True:
|
while True:
|
||||||
retcode, stdout, stderr = common.run_os_command('ceph pg dump osds --format json')
|
retcode, stdout, stderr = common.run_os_command('ceph pg dump osds --format json')
|
||||||
|
@ -209,6 +216,7 @@ def remove_osd(zk_conn, logger, osd_id, osd_obj):
|
||||||
break
|
break
|
||||||
|
|
||||||
# 3. Stop the OSD process and wait for it to be terminated
|
# 3. Stop the OSD process and wait for it to be terminated
|
||||||
|
logger.out('Stopping OSD disk with ID {}'.format(osd_id), state='i')
|
||||||
retcode, stdout, stderr = common.run_os_command('systemctl stop ceph-osd@{}'.format(osd_id))
|
retcode, stdout, stderr = common.run_os_command('systemctl stop ceph-osd@{}'.format(osd_id))
|
||||||
if retcode:
|
if retcode:
|
||||||
print('systemctl stop')
|
print('systemctl stop')
|
||||||
|
@ -228,6 +236,7 @@ def remove_osd(zk_conn, logger, osd_id, osd_obj):
|
||||||
break
|
break
|
||||||
|
|
||||||
# 4. Delete OSD from ZK
|
# 4. Delete OSD from ZK
|
||||||
|
logger.out('Deleting OSD disk with ID {} from Zookeeper'.format(osd_id), state='i')
|
||||||
zkhandler.deletekey(zk_conn, '/ceph/osds/{}'.format(osd_id))
|
zkhandler.deletekey(zk_conn, '/ceph/osds/{}'.format(osd_id))
|
||||||
|
|
||||||
# 5. Determine the block devices
|
# 5. Determine the block devices
|
||||||
|
@ -237,6 +246,7 @@ def remove_osd(zk_conn, logger, osd_id, osd_obj):
|
||||||
pv_block = stdout
|
pv_block = stdout
|
||||||
|
|
||||||
# 6. Zap the volumes
|
# 6. Zap the volumes
|
||||||
|
logger.out('Zapping OSD disk with ID {} on {}'.format(osd_id, pv_block), state='i')
|
||||||
retcode, stdout, stderr = common.run_os_command('ceph-volume lvm zap --destroy {}'.format(pv_block))
|
retcode, stdout, stderr = common.run_os_command('ceph-volume lvm zap --destroy {}'.format(pv_block))
|
||||||
if retcode:
|
if retcode:
|
||||||
print('ceph-volume lvm zap')
|
print('ceph-volume lvm zap')
|
||||||
|
@ -245,6 +255,7 @@ def remove_osd(zk_conn, logger, osd_id, osd_obj):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# 7. Purge the OSD from Ceph
|
# 7. Purge the OSD from Ceph
|
||||||
|
logger.out('Purging OSD disk with ID {}'.format(osd_id), state='i')
|
||||||
retcode, stdout, stderr = common.run_os_command('ceph osd purge {} --yes-i-really-mean-it'.format(osd_id))
|
retcode, stdout, stderr = common.run_os_command('ceph osd purge {} --yes-i-really-mean-it'.format(osd_id))
|
||||||
if retcode:
|
if retcode:
|
||||||
print('ceph osd purge')
|
print('ceph osd purge')
|
||||||
|
@ -253,7 +264,7 @@ def remove_osd(zk_conn, logger, osd_id, osd_obj):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Log it
|
# Log it
|
||||||
logger.out('Purged OSD disk with ID {}'.format(osd_id), state='o')
|
logger.out('Removed OSD disk with ID {}'.format(osd_id), state='o')
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Log it
|
# Log it
|
||||||
|
|
Loading…
Reference in New Issue