]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: generate useful error msgs for 'osd crush rule create-simple ...'
authorSage Weil <sage@inktank.com>
Fri, 3 May 2013 22:54:19 +0000 (15:54 -0700)
committerSage Weil <sage@inktank.com>
Fri, 3 May 2013 22:54:19 +0000 (15:54 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h
src/mon/OSDMonitor.cc

index e8058d60a57efa3f844b7f2b18a06a0e5b2d814f..8d07c5ec795778046c819d98d532156df2b64aa8 100644 (file)
@@ -631,17 +631,26 @@ void CrushWrapper::reweight(CephContext *cct)
   }
 }
 
-int CrushWrapper::add_simple_rule(string name, string root_name, string failure_domain_name)
+int CrushWrapper::add_simple_rule(string name, string root_name, string failure_domain_name,
+                                 ostream *err)
 {
-  if (rule_exists(name))
+  if (rule_exists(name)) {
+    if (err)
+      *err << "rule " << name << " exists";
     return -EEXIST;
-  if (!name_exists(root_name))
+  }
+  if (!name_exists(root_name)) {
+    if (err)
+      *err << "root item " << root_name << " does not exist";
     return -ENOENT;
+  }
   int root = get_item_id(root_name);
   int type = 0;
   if (failure_domain_name.length()) {
     type = get_type_id(failure_domain_name);
     if (type < 0) {
+      if (err)
+       *err << "unknown type " << failure_domain_name;
       return -EINVAL;
     }
   }
index ac936336125ccebde4641b3127f9c55dd3e28e59..ce97b29ad9da975f3c15862cc5d2cb1940199906 100644 (file)
@@ -575,7 +575,8 @@ public:
     return set_rule_step(ruleno, step, CRUSH_RULE_EMIT, 0, 0);
   }
 
-  int add_simple_rule(string name, string root_name, string failure_domain_type);
+  int add_simple_rule(string name, string root_name, string failure_domain_type,
+                     ostream *err = 0);
 
   int remove_rule(int ruleno);
 
index 75105cadadf9221884580394838d347ca73d0dee..7c5ffce48ce627c9bfa297c37ad2460047563c7f 100644 (file)
@@ -2861,7 +2861,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
        ss << "rule " << name << " already exists";
        err = 0;
       } else {
-       int rule = newcrush.add_simple_rule(name, root, type);
+       int rule = newcrush.add_simple_rule(name, root, type, &ss);
        if (rule < 0) {
          err = rule;
          goto out;