Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mimic: mon: add purge-new #23259

Merged
merged 4 commits into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions qa/workunits/cephtool/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1348,13 +1348,13 @@ function test_mon_osd_create_destroy()
ceph auth get-key osd.$id3
ceph config-key exists dm-crypt/osd/$uuid3/luks

ceph osd purge osd.$id3 --yes-i-really-mean-it
ceph osd purge-new osd.$id3 --yes-i-really-mean-it
expect_false ceph osd find $id2
expect_false ceph auth get-key osd.$id2
expect_false ceph auth get-key client.osd-lockbox.$uuid3
expect_false ceph config-key exists dm-crypt/osd/$uuid3/luks
ceph osd purge osd.$id3 --yes-i-really-mean-it
ceph osd purge osd.$id3 --yes-i-really-mean-it # idempotent
ceph osd purge-new osd.$id3 --yes-i-really-mean-it # idempotent

ceph osd purge osd.$id --yes-i-really-mean-it
ceph osd purge 123456 --yes-i-really-mean-it
Expand Down
1 change: 1 addition & 0 deletions src/mon/MonCap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ void MonCapGrant::expand_profile_mon(const EntityName& name) const
profile_grants.push_back(MonCapGrant("osd", MON_CAP_R)); // read osdmap
profile_grants.push_back(MonCapGrant("mon getmap"));
profile_grants.push_back(MonCapGrant("osd new"));
profile_grants.push_back(MonCapGrant("osd purge-new"));
}
if (profile == "bootstrap-mds") {
profile_grants.push_back(MonCapGrant("mon", MON_CAP_R)); // read monmap
Expand Down
6 changes: 6 additions & 0 deletions src/mon/MonCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,12 @@ COMMAND("osd destroy " \
"but removes cephx keys, config-key data and lockbox keys, "\
"rendering data permanently unreadable.", \
"osd", "rw", "cli,rest")
COMMAND("osd purge-new " \
"name=id,type=CephOsdName " \
"name=sure,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \
"purge all traces of an OSD that was partially created but never " \
"started", \
"osd", "rw", "cli,rest")
COMMAND("osd purge " \
"name=id,type=CephOsdName " \
"name=sure,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \
Expand Down
19 changes: 16 additions & 3 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7774,7 +7774,10 @@ int OSDMonitor::prepare_command_osd_new(
assert(id >= 0);
assert(osdmap.is_destroyed(id));
pending_inc.new_weight[id] = CEPH_OSD_OUT;
pending_inc.new_state[id] |= CEPH_OSD_DESTROYED | CEPH_OSD_NEW;
pending_inc.new_state[id] |= CEPH_OSD_DESTROYED;
if ((osdmap.get_state(id) & CEPH_OSD_NEW) == 0) {
pending_inc.new_state[id] |= CEPH_OSD_NEW;
}
if (osdmap.get_state(id) & CEPH_OSD_UP) {
// due to http://tracker.ceph.com/issues/20751 some clusters may
// have UP set for non-existent OSDs; make sure it is cleared
Expand Down Expand Up @@ -10581,7 +10584,9 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
return true;
}

} else if (prefix == "osd destroy" || prefix == "osd purge") {
} else if (prefix == "osd destroy" ||
prefix == "osd purge" ||
prefix == "osd purge-new") {
/* Destroying an OSD means that we don't expect to further make use of
* the OSDs data (which may even become unreadable after this operation),
* and that we are okay with scrubbing all its cephx keys and config-key
Expand Down Expand Up @@ -10612,7 +10617,8 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,

bool is_destroy = (prefix == "osd destroy");
if (!is_destroy) {
assert("osd purge" == prefix);
assert("osd purge" == prefix ||
"osd purge-new" == prefix);
}

string sure;
Expand All @@ -10637,6 +10643,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
goto reply;
}

if (prefix == "osd purge-new" &&
(osdmap.get_state(id) & CEPH_OSD_NEW) == 0) {
ss << "osd." << id << " is not new";
err = -EPERM;
goto reply;
}

bool goto_reply = false;

paxos->plug();
Expand Down