]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: set ceph osd (down|out|in|rm) error code on failure
authorLoic Dachary <loic@dachary.org>
Sun, 15 Dec 2013 15:27:02 +0000 (16:27 +0100)
committerSage Weil <sage@inktank.com>
Mon, 30 Dec 2013 21:07:12 +0000 (13:07 -0800)
Instead of always returning true, the error code is set if at least one
operation fails.

EINVAL if the OSD id is invalid (osd.foobar for instance).
EBUSY if trying to remove and OSD that is up.

When used with the ceph command line, it looks like this:

    ceph -c ceph.conf osd rm osd.0
    Error EBUSY: osd.0 is still up; must be down before removal.
    kill PID_OF_osd.0
    ceph -c ceph.conf osd down osd.0
    marked down osd.0.
    ceph -c ceph.conf osd rm osd.0 osd.1
    Error EBUSY: removed osd.0, osd.1 is still up; must be down before removal.

http://tracker.ceph.com/issues/6824 fixes #6824

Signed-off-by: Loic Dachary <loic@dachary.org>
(cherry picked from commit 15b8616b13a327701c5d48c6cb7aeab8fcc4cafc)

src/mon/OSDMonitor.cc

index 58491263f36e1d58255496d486bbff94499f48e2..c0b843a1233209edf417ac79a7ad5f4a1e38dddd 100644 (file)
@@ -3156,17 +3156,15 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
       long osd = parse_osd_id(idvec[j].c_str(), &ss);
       if (osd < 0) {
        ss << "invalid osd id" << osd;
-       // XXX -EINVAL here?
+       err = -EINVAL;
        continue;
       } else if (!osdmap.exists(osd)) {
        ss << "osd." << osd << " does not exist. ";
-       err = 0;
        continue;
       }
       if (prefix == "osd down") {
        if (osdmap.is_down(osd)) {
          ss << "osd." << osd << " is already down. ";
-         err = 0;
        } else {
          pending_inc.new_state[osd] = CEPH_OSD_UP;
          ss << "marked down osd." << osd << ". ";
@@ -3175,7 +3173,6 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
       } else if (prefix == "osd out") {
        if (osdmap.is_out(osd)) {
          ss << "osd." << osd << " is already out. ";
-         err = 0;
        } else {
          pending_inc.new_weight[osd] = CEPH_OSD_OUT;
          ss << "marked out osd." << osd << ". ";
@@ -3184,7 +3181,6 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
       } else if (prefix == "osd in") {
        if (osdmap.is_in(osd)) {
          ss << "osd." << osd << " is already in. ";
-         err = 0;
        } else {
          pending_inc.new_weight[osd] = CEPH_OSD_IN;
          ss << "marked in osd." << osd << ". ";
@@ -3192,7 +3188,10 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
        }
       } else if (prefix == "osd rm") {
        if (osdmap.is_up(osd)) {
+         if (any)
+           ss << ", ";
           ss << "osd." << osd << " is still up; must be down before removal. ";
+         err = -EBUSY;
        } else {
          pending_inc.new_state[osd] = osdmap.get_state(osd);
           pending_inc.new_uuid[osd] = uuid_d();
@@ -3207,7 +3206,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
     }
     if (any) {
       getline(ss, rs);
-      wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed()));
+      wait_for_finished_proposal(new Monitor::C_Command(mon, m, err, rs, get_last_committed()));
       return true;
     }
   } else if (prefix == "osd reweight") {