Skip to content

Commit 1033251

Browse files
committed
mgr/cephadm: handle setting required osd release with no OSDs during upgrade
A change to the `ceph osd require-osd-release` command made it so it fails if no OSDs are up unless --yes-i-really-mean-it is passed. For real clusters this is likely not an issue, but it can be an annoyance for trying upgrades on test clusters that may not have OSDs deployed. This patch is to try and just pass the flag in cases where we have no OSDs rather than failing the upgrade Signed-off-by: Adam King <[email protected]>
1 parent becfb26 commit 1033251

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/pybind/mgr/cephadm/upgrade.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from cephadm.ssh import HostConnectionError
1414
from orchestrator import OrchestratorError, DaemonDescription, DaemonDescriptionStatus, daemon_type_to_service
1515

16+
from mgr_module import MonCommandFailed
17+
1618
if TYPE_CHECKING:
1719
from .module import CephadmOrchestrator
1820

@@ -980,10 +982,32 @@ def _complete_osd_upgrade(self, target_major: str, target_major_name: str) -> No
980982
if osd_min < int(target_major):
981983
logger.info(
982984
f'Upgrade: Setting require_osd_release to {target_major} {target_major_name}')
983-
ret, _, err = self.mgr.check_mon_command({
984-
'prefix': 'osd require-osd-release',
985-
'release': target_major_name,
986-
})
985+
try:
986+
ret, out, err = self.mgr.check_mon_command({
987+
'prefix': 'osd require-osd-release',
988+
'release': target_major_name,
989+
})
990+
except MonCommandFailed as e:
991+
# recently it was changed so that `ceph osd require-osd-release`
992+
# will fail if run on a cluster with no OSDs unless --yes-i-really-mean-it
993+
# is passed. If we get that specific failure and we actually have no OSD
994+
# daemons, we should just try to pass the flag
995+
if "no OSDs are up" in str(e):
996+
if not self.mgr.cache.get_daemons_by_type('osd'):
997+
# this is the case where we actually have no OSDs in the cluster
998+
ret, _, err = self.mgr.check_mon_command({
999+
'prefix': 'osd require-osd-release',
1000+
'release': target_major_name,
1001+
'yes_i_really_mean_it': True
1002+
})
1003+
else:
1004+
# this is the case where we do have OSDs listed, but none of them are up
1005+
raise OrchestratorError(
1006+
'All OSDs down, causing a failure setting the minimum required OSD release. '
1007+
'If you are sure you\'d like to move forward, please run '
1008+
'"ceph osd require-osd-release --yes-i-really-mean-it" then resume the upgrade')
1009+
else:
1010+
raise
9871011

9881012
def _complete_mds_upgrade(self) -> None:
9891013
assert self.upgrade_state is not None

0 commit comments

Comments
 (0)