Delete ceph stor when removing controller

When removing controller from cluster, its OSD is not being removed
from ceph. This happens when removal is made by issuing "host-delete"
command.

This commit adds a call to remove the OSD from Ceph when controller is
removed.

Closes-Bug: #1926626

Signed-off-by: Vinicius Lopes da Silva <vinicius.lopesdasilva@windriver.com>
Change-Id: If0fd9260ab7b9c717ef0a4ae621da0ffc9d0e6ab
This commit is contained in:
Vinicius Lopes da Silva 2021-04-29 10:55:40 -04:00
parent 3e3ac96bb7
commit eec51d6a4a
2 changed files with 7 additions and 5 deletions

View File

@ -2491,12 +2491,14 @@ class HostController(rest.RestController):
ceph_mons[0].uuid, {'device_path': None}
)
remove_from_cluster = True if ihost.invprovision == constants.PROVISIONED else False
# Delete the stor entries associated with this host
istors = pecan.request.dbapi.istor_get_by_ihost(ihost['uuid'])
for stor in istors:
try:
self.istors.delete_stor(stor.uuid)
self.istors.delete_stor(stor.uuid, remove_from_cluster)
except Exception as e:
# Do not destroy the ihost if the stor cannot be deleted.
LOG.exception(e)

View File

@ -497,7 +497,7 @@ class StorageController(rest.RestController):
constants.STOR_FUNCTION_OSD,
constants.SB_STATE_CONFIGURING_ON_UNLOCK))
def delete_stor(self, stor_uuid):
def delete_stor(self, stor_uuid, remove_from_cluster=False):
"""Delete a stor"""
stor = objects.storage.get_by_uuid(pecan.request.context, stor_uuid)
@ -505,9 +505,9 @@ class StorageController(rest.RestController):
try:
# The conductor will handle removing the stor, not all functions
# need special handling
# if stor.function == constants.STOR_FUNCTION_OSD:
# pecan.request.rpcapi.unconfigure_osd_istor(pecan.request.context,
# stor)
if stor.function == constants.STOR_FUNCTION_OSD and remove_from_cluster:
pecan.request.rpcapi.unconfigure_osd_istor(pecan.request.context,
stor)
if stor.function == constants.STOR_FUNCTION_JOURNAL:
pecan.request.dbapi.istor_disable_journal(stor_uuid)
# Now remove the stor from DB