Skip to content

Commit

Permalink
mon : add osdmap flags set and unset message when
Browse files Browse the repository at this point in the history
osdmap flags are already set and unset

Fixes: http://tracker.ceph.com/issues/15983

Signed-off-by: Vikhyat Umrao <vumrao@redhat.com>
  • Loading branch information
vumrao committed May 25, 2016
1 parent 9b187f2 commit 9729bba
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
18 changes: 18 additions & 0 deletions qa/workunits/cephtool/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1084,11 +1084,29 @@ function test_mon_osd()
for f in noup nodown noin noout noscrub nodeep-scrub nobackfill norebalance norecover notieragent full sortbitwise
do
ceph osd set $f
if [[ "$f" == "sortbitwise" ]]; then
expect_failure $TMPDIR "sortbitwise flag is already set"
fi
ceph osd unset $f
if [[ "$f" == "full" ]]; then
# As full flag gets unset if there wont be any OSD in cluster which is full
# Not taking failure as it gets unset by default
expect_failure $TMPDIR "full flag is not set" || return 0
fi
done
ceph osd set sortbitwise # new backends cant handle nibblewise
expect_failure $TMPDIR "sortbitwise flag is already set"
expect_false ceph osd set bogus
expect_false ceph osd unset bogus

ceph osd set noout >& $TMPFILE || return 1
check_response "set noout"
ceph osd set noout >& $TMPFILE || return 1
expect_failure $TMPDIR "noout flag is already set"
ceph osd unset noout >& $TMPFILE || return 1
check_response "unset noout"
ceph osd unset noout >& $TMPFILE || return 1
expect_failure $TMPDIR "noout flag is not set"

ceph osd set noup
ceph osd down 0
Expand Down
16 changes: 12 additions & 4 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4806,8 +4806,12 @@ bool OSDMonitor::prepare_set_flag(MonOpRequestRef op, int flag)
ostringstream ss;
if (pending_inc.new_flags < 0)
pending_inc.new_flags = osdmap.get_flags();
pending_inc.new_flags |= flag;
ss << "set " << OSDMap::get_flag_string(flag);
if (osdmap.test_flag(flag)) {
ss << OSDMap::get_flag_string(flag) << " flag is already set";
} else {
pending_inc.new_flags |= flag;
ss << "set " << OSDMap::get_flag_string(flag);
}
wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, ss.str(),
get_last_committed() + 1));
return true;
Expand All @@ -4819,8 +4823,12 @@ bool OSDMonitor::prepare_unset_flag(MonOpRequestRef op, int flag)
ostringstream ss;
if (pending_inc.new_flags < 0)
pending_inc.new_flags = osdmap.get_flags();
pending_inc.new_flags &= ~flag;
ss << "unset " << OSDMap::get_flag_string(flag);
if (!osdmap.test_flag(flag)) {
ss << OSDMap::get_flag_string(flag) << " flag is not set";
} else {
pending_inc.new_flags &= ~flag;
ss << "unset " << OSDMap::get_flag_string(flag);
}
wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, ss.str(),
get_last_committed() + 1));
return true;
Expand Down

0 comments on commit 9729bba

Please sign in to comment.