Changes the number of monitors required to unlock storage

When there is only one monitor available on a storage system,
for example, the standby controller and storage-0 are locked,
we should first unlock the controller, and only then can we
unlock storage-0.

To fix this, the storage unlock check has been modified so
that if it is storage-0 and already provisioned, only one
monitor is required to perform the unlock.

This allows quorum to be reestablished as quickly as possible.

Test Plan:
  PASS: Lock controller (not active) and storage-0
  PASS: Unlock storage-0 and controller

  PASS: Lock storage-0 and controller (not active)
  PASS: Unlock storage-0 and controller

  PASS: Lock controller (not active) and storage-0
  PASS: Unlock controller and storage-0

  PASS: Lock storage-0 and controller (not active)
  PASS: Unlock controller and storage-0

  PASS: Lock controller (not active), storage-1
        and reboot storage-0
  PASS: Unlock storage-1

  PASS: Lock controller (not active)
        and reinstall storage-0

  PASS: In fresh install, shutdown controller
        (not active) before unlocking storage-0

Closes-Bug: 2062569

Change-Id: I335be06c9dd17d5e099a7914955d4f7bf5f3b32e
Signed-off-by: Erickson Silva de Oliveira <Erickson.SilvadeOliveira@windriver.com>
This commit is contained in:
Erickson Silva de Oliveira 2024-04-19 10:51:23 -03:00
parent 4f66b01ad8
commit 30edc5737e
2 changed files with 8 additions and 1 deletions

View File

@ -6241,6 +6241,13 @@ class HostController(rest.RestController):
ceph_helper = ceph.CephApiOperator()
num_monitors, required_monitors, __ = \
ceph_helper.get_monitors_status(pecan.request.dbapi)
# Checks that the hostname is storage-0 and is provisioned
# to determine that only one monitor is needed to perform the unlock.
# This allows quorum to be reestablished as quickly as possible.
if ihost['hostname'] == "storage-0" and ihost['invprovision'] == constants.PROVISIONED:
required_monitors = 1
if num_monitors < required_monitors:
raise wsme.exc.ClientSideError(
_("Can not unlock storage node. Only %d storage "

View File

@ -602,7 +602,7 @@ def check_node_lock_ceph_mon(ihost, unsafe=False, ceph_helper=None):
"monitor available. At least %d unlocked and "
"enabled hosts with monitors are required. Please"
" ensure hosts with monitors are unlocked and "
"enabled."
"enabled. "
"Use --force --unsafe if you wish to lock anyway.") %
(num_monitors, required_monitors))