Skip to contentSkip to conversation

crushtool: fix args parsing

PATCH In review Henry C Chang 2 participants 5 messages Sep 22, 2011 – Sep 23, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crushtool: fix args parsing

Fix --add-item and --loc args parsing.

---
 src/crushtool.cc |   13 +------------
 1 files changed, 1 insertions(+), 12 deletions(-)
src/crushtool.cc +1 -12
index 51531aa..f0ccb9b 100644
@@ -872,9 +872,6 @@ int main(int argc, const char **argv)
       }
       if (i == args.end())
 	usage();
-      i = args.erase(i);
-      if (i == args.end())
-	usage();
       add_weight = atof(*i);
       i = args.erase(i);
       if (i == args.end())
@@ -885,9 +882,6 @@ int main(int argc, const char **argv)
       std::string type(val);
       if (i == args.end())
 	usage();
-      i = args.erase(i);
-      if (i == args.end())
-	usage();
       std::string name(*i);
       i = args.erase(i);
       add_loc[type] = name;
@@ -897,9 +891,6 @@ int main(int argc, const char **argv)
       reweight_name = val;
       if (i == args.end())
 	usage();
-      i = args.erase(i);
-      if (i == args.end())
-	usage();
       reweight_weight = atof(*i);
       i = args.erase(i);
     } else if (ceph_argparse_flag(args, i, "--build", (char*)NULL)) {
@@ -954,10 +945,8 @@ int main(int argc, const char **argv)
       int dev = tmp;
       if (i == args.end())
 	usage();
-      i = args.erase(i);
-      if (i == args.end())
-	usage();
       float f = atof(*i);
+      i = args.erase(i);
       int w = (int)(f * 0x10000);
       if (w < 0)
 	w = 0;
Signature · 1 line
1.7.4.1
#1 lore raw

Hey Henry-

Do you have a list of commands that were failing handy? I'd like to extend the cli unit tests at the same time (src/test/cli/crushtool).

Thanks-
sage

Quoted 62 lines · Henry C Chang

Fix --add-item and --loc args parsing.

---
 src/crushtool.cc |   13 +------------
 1 files changed, 1 insertions(+), 12 deletions(-)
src/crushtool.cc +1 -12
index 51531aa..f0ccb9b 100644
@@ -872,9 +872,6 @@ int main(int argc, const char **argv)
       }
       if (i == args.end())
 	usage();
-      i = args.erase(i);
-      if (i == args.end())
-	usage();
       add_weight = atof(*i);
       i = args.erase(i);
       if (i == args.end())
@@ -885,9 +882,6 @@ int main(int argc, const char **argv)
       std::string type(val);
       if (i == args.end())
 	usage();
-      i = args.erase(i);
-      if (i == args.end())
-	usage();
       std::string name(*i);
       i = args.erase(i);
       add_loc[type] = name;
@@ -897,9 +891,6 @@ int main(int argc, const char **argv)
       reweight_name = val;
       if (i == args.end())
 	usage();
-      i = args.erase(i);
-      if (i == args.end())
-	usage();
       reweight_weight = atof(*i);
       i = args.erase(i);
     } else if (ceph_argparse_flag(args, i, "--build", (char*)NULL)) {
@@ -954,10 +945,8 @@ int main(int argc, const char **argv)
       int dev = tmp;
       if (i == args.end())
 	usage();
-      i = args.erase(i);
-      if (i == args.end())
-	usage();
       float f = atof(*i);
+      i = args.erase(i);
       int w = (int)(f * 0x10000);
       if (w < 0)
 	w = 0;
Signature · 6 lines
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Hi Sage,

In fact, I got two problems with the crushtool after upgrading from 0.34 to 0.35.

1. crushtool failed to parse args.

I have a template crushmap (as attached) which only consists of the root. For each disk, I will use the crushtool to add it to the crushmap. The command series look like:

$ crushtool -i /etc/ceph/crush.template --add-item 0 1.0 device0 --loc
host host0 --loc cluster cluster0 -o /tmp/crush0
$ crushtool -i /tmp/crush0 --add-item 1 1.0 device1 --loc host host0
--loc cluster cluster0 -o /tmp/crush1

2. crushtool rejected the command due to the commit 58f98e7.

I inverted the commit when upgrading to v0.35.

Henry

2011/9/23 Sage Weil <[email protected]>:

Quoted 74 lines

Hey Henry-

Do you have a list of commands that were failing handy?  I'd like to extend the cli unit tests at the same time (src/test/cli/crushtool).

Thanks-
sage

Quoted 62 lines · Henry C Chang

Fix --add-item and --loc args parsing.

---
 src/crushtool.cc |   13 +------------

 1 files changed, 1 insertions(+), 12 deletions(-)
src/crushtool.cc +1 -13
index 51531aa..f0ccb9b 100644
@@ -872,9 +872,6 @@ int main(int argc, const char **argv)
        }
        if (i == args.end())
       usage();
-      i = args.erase(i);
-      if (i == args.end())
-     usage();
        add_weight = atof(*i);
        i = args.erase(i);
        if (i == args.end())
@@ -885,9 +882,6 @@ int main(int argc, const char **argv)
        std::string type(val);
        if (i == args.end())
       usage();
-      i = args.erase(i);
-      if (i == args.end())
-     usage();
        std::string name(*i);
        i = args.erase(i);
        add_loc[type] = name;
@@ -897,9 +891,6 @@ int main(int argc, const char **argv)
        reweight_name = val;
        if (i == args.end())
       usage();
-      i = args.erase(i);
-      if (i == args.end())
-     usage();
        reweight_weight = atof(*i);
        i = args.erase(i);
      } else if (ceph_argparse_flag(args, i, "--build", (char*)NULL)) {
@@ -954,10 +945,8 @@ int main(int argc, const char **argv)
        int dev = tmp;
        if (i == args.end())
       usage();
-      i = args.erase(i);
-      if (i == args.end())
-     usage();
        float f = atof(*i);
+      i = args.erase(i);
        int w = (int)(f * 0x10000);
        if (w < 0)
       w = 0;
--

1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 17 lines · Henry C Chang

Hi Sage,

In fact, I got two problems with the crushtool after upgrading from 0.34 to 0.35.

1. crushtool failed to parse args.

I have a template crushmap (as attached) which only consists of the root. For each disk, I will use the crushtool to add it to the crushmap. The command series look like:

$ crushtool -i /etc/ceph/crush.template --add-item 0 1.0 device0 --loc
host host0 --loc cluster cluster0 -o /tmp/crush0
$ crushtool -i /tmp/crush0 --add-item 1 1.0 device1 --loc host host0
--loc cluster cluster0 -o /tmp/crush1
Quoted 3 lines

2. crushtool rejected the command due to the commit 58f98e7.

I inverted the commit when upgrading to v0.35.

Yep, those were both broken. Fixed it in the stable branch, and added a simple unit test to make sure it stays that way. Please let me know it if gives you any further problems.

Thanks!
sage

Quoted 79 lines

Henry

2011/9/23 Sage Weil <[email protected]>:

Quoted 74 lines

Hey Henry-

Do you have a list of commands that were failing handy?  I'd like to extend the cli unit tests at the same time (src/test/cli/crushtool).

Thanks-
sage

Quoted 62 lines · Henry C Chang

Fix --add-item and --loc args parsing.

---
 src/crushtool.cc |   13 +------------

 1 files changed, 1 insertions(+), 12 deletions(-)
src/crushtool.cc +1 -13
index 51531aa..f0ccb9b 100644
@@ -872,9 +872,6 @@ int main(int argc, const char **argv)
        }
        if (i == args.end())
       usage();
-      i = args.erase(i);
-      if (i == args.end())
-     usage();
        add_weight = atof(*i);
        i = args.erase(i);
        if (i == args.end())
@@ -885,9 +882,6 @@ int main(int argc, const char **argv)
        std::string type(val);
        if (i == args.end())
       usage();
-      i = args.erase(i);
-      if (i == args.end())
-     usage();
        std::string name(*i);
        i = args.erase(i);
        add_loc[type] = name;
@@ -897,9 +891,6 @@ int main(int argc, const char **argv)
        reweight_name = val;
        if (i == args.end())
       usage();
-      i = args.erase(i);
-      if (i == args.end())
-     usage();
        reweight_weight = atof(*i);
        i = args.erase(i);
      } else if (ceph_argparse_flag(args, i, "--build", (char*)NULL)) {
@@ -954,10 +945,8 @@ int main(int argc, const char **argv)
        int dev = tmp;
        if (i == args.end())
       usage();
-      i = args.erase(i);
-      if (i == args.end())
-     usage();
        float f = atof(*i);
+      i = args.erase(i);
        int w = (int)(f * 0x10000);
        if (w < 0)
       w = 0;
--

1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 4 lines

Yep, those were both broken.  Fixed it in the stable branch, and added a simple unit test to make sure it stays that way.  Please let me know it if gives you any further problems.

I can't see your commit on github. Have you pushed it on?

Henry
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html