From 66690ea3143ac5097f7c7f3118f2d00fed30cc4b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 5 Dec 2019 12:59:31 -0600 Subject: [PATCH] mgr/DaemonServer: fix 'osd ok-to-stop' for EC pools We need to pay attention to account for CRUSH_ITEM_NONE entries in the EC PG acting set. Fixes: https://tracker.ceph.com/issues/43151 Signed-off-by: Sage Weil --- qa/standalone/misc/ok-to-stop.sh | 48 ++++++++++++++++++++++++++++++++ src/mgr/DaemonServer.cc | 8 ++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/qa/standalone/misc/ok-to-stop.sh b/qa/standalone/misc/ok-to-stop.sh index e53b28d1eb28b..5e4a4180d9c7e 100755 --- a/qa/standalone/misc/ok-to-stop.sh +++ b/qa/standalone/misc/ok-to-stop.sh @@ -237,5 +237,53 @@ function TEST_0_mds() { kill_daemons $dir KILL mds.a } +function TEST_0_osd() { + local dir=$1 + + CEPH_ARGS="$ORIG_CEPH_ARGS --mon-host=$CEPH_MON_A " + + run_mon $dir a --public-addr=$CEPH_MON_A || return 1 + run_mgr $dir x || return 1 + run_osd $dir 0 || return 1 + run_osd $dir 1 || return 1 + run_osd $dir 2 || return 1 + run_osd $dir 3 || return 1 + + ceph osd erasure-code-profile set ec-profile m=2 k=2 crush-failure-domain=osd || return 1 + ceph osd pool create ec erasure ec-profile || return 1 + + wait_for_clean || return 1 + + # with min_size 3, we can stop only 1 osd + ceph osd pool set ec min_size 3 || return 1 + flush_pg_stats || return 1 + + ceph osd ok-to-stop 0 || return 1 + ceph osd ok-to-stop 1 || return 1 + ceph osd ok-to-stop 2 || return 1 + ceph osd ok-to-stop 3 || return 1 + ! ceph osd ok-to-stop 0 1 || return 1 + ! ceph osd ok-to-stop 2 3 || return 1 + + # with min_size 2 we can stop 1 osds + ceph osd pool set ec min_size 2 || return 1 + flush_pg_stats || return 1 + + ceph osd ok-to-stop 0 1 || return 1 + ceph osd ok-to-stop 2 3 || return 1 + ! ceph osd ok-to-stop 0 1 2 || return 1 + ! ceph osd ok-to-stop 1 2 3 || return 1 + + # we should get the same result with one of the osds already down + kill_daemons $dir TERM osd.0 || return 1 + ceph osd down 0 || return 1 + flush_pg_stats || return 1 + + ceph osd ok-to-stop 0 || return 1 + ceph osd ok-to-stop 0 1 || return 1 + ! ceph osd ok-to-stop 0 1 2 || return 1 + ! ceph osd ok-to-stop 1 2 3 || return 1 +} + main ok-to-stop "$@" diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 7b81ffff02720..2bc739157e039 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -1588,7 +1588,9 @@ bool DaemonServer::_handle_command( found = true; continue; } - pg_acting.insert(anm.osd); + if (anm.osd != CRUSH_ITEM_NONE) { + pg_acting.insert(anm.osd); + } } } else { for (auto& a : q.second.acting) { @@ -1596,7 +1598,9 @@ bool DaemonServer::_handle_command( found = true; continue; } - pg_acting.insert(a); + if (a != CRUSH_ITEM_NONE) { + pg_acting.insert(a); + } } } if (!found) { -- 2.39.5