Compare commits

..

No commits in common. "d18e009b00d3422aa9f79686089e46b184266597" and "d2757004dbc95254e7f5c08fe5caac1bf47483f1" have entirely different histories.

2 changed files with 47 additions and 53 deletions

View File

@ -370,22 +370,13 @@ def format_list_osd(osd_list):
# If this happens, the node hasn't checked in fully yet, so use some dummy data # If this happens, the node hasn't checked in fully yet, so use some dummy data
if osd_information["stats"]["node"] == "|": if osd_information["stats"]["node"] == "|":
for key in osd_information["stats"].keys(): for key in osd_information["stats"].keys():
if ( if osd_information["stats"][key] == "|":
osd_information["stats"][key] == "|" osd_information["stats"][key] = "N/A"
or osd_information["stats"][key] is None elif osd_information["stats"][key] is None:
):
osd_information["stats"][key] = "N/A" osd_information["stats"][key] = "N/A"
for key in osd_information.keys(): for key in osd_information.keys():
if osd_information[key] is None: if osd_information[key] is None:
osd_information[key] = "N/A" osd_information[key] = "N/A"
else:
for key in osd_information["stats"].keys():
if key in ["utilization", "var"] and isinstance(
osd_information["stats"][key], float
):
osd_information["stats"][key] = round(
osd_information["stats"][key], 2
)
except KeyError: except KeyError:
print( print(
f"Details for OSD {osd_information['id']} missing required keys, skipping." f"Details for OSD {osd_information['id']} missing required keys, skipping."
@ -458,11 +449,13 @@ def format_list_osd(osd_list):
if _osd_free_length > osd_free_length: if _osd_free_length > osd_free_length:
osd_free_length = _osd_free_length osd_free_length = _osd_free_length
_osd_util_length = len(str(osd_information["stats"]["utilization"])) + 1 osd_util = round(osd_information["stats"]["utilization"], 2)
_osd_util_length = len(str(osd_util)) + 1
if _osd_util_length > osd_util_length: if _osd_util_length > osd_util_length:
osd_util_length = _osd_util_length osd_util_length = _osd_util_length
_osd_var_length = len(str(osd_information["stats"]["var"])) + 1 osd_var = round(osd_information["stats"]["var"], 2)
_osd_var_length = len(str(osd_var)) + 1
if _osd_var_length > osd_var_length: if _osd_var_length > osd_var_length:
osd_var_length = _osd_var_length osd_var_length = _osd_var_length
@ -612,6 +605,8 @@ def format_list_osd(osd_list):
osd_up_flag, osd_up_colour, osd_in_flag, osd_in_colour = getOutputColoursOSD( osd_up_flag, osd_up_colour, osd_in_flag, osd_in_colour = getOutputColoursOSD(
osd_information osd_information
) )
osd_util = round(osd_information["stats"]["utilization"], 2)
osd_var = round(osd_information["stats"]["var"], 2)
osd_db_device = osd_information["db_device"] osd_db_device = osd_information["db_device"]
if not osd_db_device: if not osd_db_device:
@ -674,8 +669,8 @@ def format_list_osd(osd_list):
osd_reweight=osd_information["stats"]["reweight"], osd_reweight=osd_information["stats"]["reweight"],
osd_used=osd_information["stats"]["used"], osd_used=osd_information["stats"]["used"],
osd_free=osd_information["stats"]["avail"], osd_free=osd_information["stats"]["avail"],
osd_util=osd_information["stats"]["utilization"], osd_util=osd_util,
osd_var=osd_information["stats"]["var"], osd_var=osd_var,
osd_wrops=osd_information["stats"]["wr_ops"], osd_wrops=osd_information["stats"]["wr_ops"],
osd_wrdata=osd_information["stats"]["wr_data"], osd_wrdata=osd_information["stats"]["wr_data"],
osd_rdops=osd_information["stats"]["rd_ops"], osd_rdops=osd_information["stats"]["rd_ops"],

View File

@ -434,7 +434,7 @@ class CephOSDInstance(object):
(("osd.lv", osd_id), osd_lv), (("osd.lv", osd_id), osd_lv),
( (
("osd.stats", osd_id), ("osd.stats", osd_id),
'{"uuid": "|", "up": 0, "in": 0, "primary_affinity": "|", "utilization": "|", "var": "|", "pgs": "|", "kb": "|", "weight": "|", "reweight": "|", "node": "|", "used": "|", "avail": "|", "wr_ops": "|", "wr_data": "|", "rd_ops": "|", "rd_data": "|", "state": "|"}', f'{"uuid": "|", "up": 0, "in": 0, "primary_affinity": "|", "utilization": "|", "var": "|", "pgs": "|", "kb": "|", "weight": "|", "reweight": "|", "node": "{node}", "used": "|", "avail": "|", "wr_ops": "|", "wr_data": "|", "rd_ops": "|", "rd_data": "|", state="|" }',
), ),
] ]
) )
@ -542,48 +542,47 @@ class CephOSDInstance(object):
break break
# 4. Determine the block devices # 4. Determine the block devices
osd_vg = zkhandler.read(("osd.vg", osd_id)) device_zk = zkhandler.read(("osd.device", osd_id))
osd_lv = zkhandler.read(("osd.lv", osd_id)) try:
osd_lvm = f"/dev/{osd_vg}/{osd_lv}" retcode, stdout, stderr = common.run_os_command(
osd_device = None "readlink /var/lib/ceph/osd/ceph-{}/block".format(osd_id)
)
vg_name = stdout.split("/")[
-2
] # e.g. /dev/ceph-<uuid>/osd-block-<uuid>
retcode, stdout, stderr = common.run_os_command(
"vgs --separator , --noheadings -o pv_name {}".format(vg_name)
)
pv_block = stdout.strip()
except Exception as e:
print(e)
pv_block = device_zk
# 5a. Verify that the blockdev actually has a ceph volume that matches the ID, otherwise don't zap it
logger.out( logger.out(
f"Getting disk info for OSD {osd_id} LV {osd_lvm}", f"Check OSD disk {pv_block} for OSD signature with ID osd.{osd_id}",
state="i", state="i",
) )
retcode, stdout, stderr = common.run_os_command( retcode, stdout, stderr = common.run_os_command(
f"ceph-volume lvm list {osd_lvm}" f"ceph-volume lvm list {pv_block}"
) )
for line in stdout.split("\n"): if f"====== osd.{osd_id} =======" in stdout:
if "devices" in line: # 5b. Zap the volumes
osd_device = line.split()[-1] logger.out(
"Zapping OSD disk with ID {} on {}".format(osd_id, pv_block),
if not osd_device: state="i",
print("ceph-volume lvm list") )
print("Could not find OSD information in data:") retcode, stdout, stderr = common.run_os_command(
print(stdout) "ceph-volume lvm zap --destroy {}".format(pv_block)
print(stderr) )
if force_flag: if retcode:
logger.out("Ignoring error due to force flag", state="i") print("ceph-volume lvm zap")
else: print(stdout)
raise Exception print(stderr)
if force_flag:
# 5. Zap the volumes logger.out("Ignoring error due to force flag", state="i")
logger.out( else:
"Zapping OSD {} disk on {}".format(osd_id, osd_device), raise Exception
state="i",
)
retcode, stdout, stderr = common.run_os_command(
"ceph-volume lvm zap --destroy {}".format(osd_device)
)
if retcode:
print("ceph-volume lvm zap")
print(stdout)
print(stderr)
if force_flag:
logger.out("Ignoring error due to force flag", state="i")
else:
raise Exception
# 6. Purge the OSD from Ceph # 6. Purge the OSD from Ceph
logger.out("Purging OSD disk with ID {}".format(osd_id), state="i") logger.out("Purging OSD disk with ID {}".format(osd_id), state="i")