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
FixForBug#2862 #4172
FixForBug#2862 #4172
Conversation
Fixes: #2862 Changes related to rbd file Changes to rbd.cc ----------------- Change 1: line# 2744 to 2747 If the option is --order then do the check of its value if its less than 12 or greaterthan 25 then throw error. Correct value of --order is 12 to 25. Change 2: Removal of validation from line# 3205 to 3209 Since the check for correct value of --order is done before hence the check here is not needed. Signed-off-by: Rajesh Nambiar <rajesh.n@msystechnologies.com>
Fix#: 2862 Changes to some of the common files for command line parsing Change to ceph_argparse.cc ------------------------- Added function ceph_arg_value_type() Given an input it will determine i) If that input is an option or not ii) If input is numeric in nature or not. It will set the flag boolOption and boolNumeric appropriately. This function is called by ceph_argparse_withlonglong() and ceph_argparse_withint() to figure out if the input parameter to those functions are numeric in nature and not an option. If the input parameter to ceph_argparse_withlonglong()/ceph_argparse_withint() happens to be an option then it implies that user didn't supply value to the option. Changes to strol.cc ------------------- Changes to strict_strtoll() and strict_strtol() Both these functions reponsibility is to convert the string to long or to int. I felt it may be not be good for it to display error message within this function, rather caller of this function who has better understanding of the function's purpose can display the error message. Made change in this function to just create a generic error message,Its the caller of this function decides what to do with this message. Signed-off-by: Rajesh Nambiar <rajesh.n@msystechnologies.com>
For the local sanity test to pass this change is needed as the output message changes. Signed-off-by: Rajesh Nambiar <rajesh.n@msystechnologies.com>
SUCCESS: the output of run-make-check.sh on centos-7 for 0ceaea2 is http://paste2.org/1smy9n7I |
Fixes: Bug # 2861 Once we have deduced image/pool/snap name from command line, validate them If invalid then bail out with appropriate error. Signed-off-by: Rajesh Nambiar <rajesh.n@msystechnologies.com>
SUCCESS: the output of run-make-check.sh on centos-7 for 41bdf90 is http://paste2.org/dNa5PMwt |
I have comited fix for Bug#2861 just now |
Greetings! |
@@ -3034,6 +3064,28 @@ if (!set_conf_param(v, p1, p2, p3)) { \ | |||
// the relevant parts | |||
set_pool_image_name(imgname, (char **)&poolname, | |||
(char **)&imgname, (char **)&snapname); | |||
|
|||
if(!is_valid_name(poolname) || !is_valid_name(snapname) || !is_valid_name(imgname)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these if statements should be a lot simpler. Build an error string from the names "pool" "snap" "image" and depending on how many invalid items either separate with a "," and/or "and."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense.
Previous changes of mine were calling is_valid_name() for the same name
multiple times, which is not needed. Did necessary changes as suggested by
you.
On Tue, Mar 31, 2015 at 2:14 AM, David Zafman notifications@github.com
wrote:
In src/rbd.cc
#4172 (comment):@@ -3034,6 +3064,28 @@ if (!set_conf_param(v, p1, p2, p3)) {
// the relevant parts
set_pool_image_name(imgname, (char *)&poolname,
(char *)&imgname, (char **)&snapname);
+
- if(!is_valid_name(poolname) || !is_valid_name(snapname) || !is_valid_name(imgname)) {
All these if statements should be a lot simpler. Build an error string
from the names "pool" "snap" "image" and depending on how many invalid
items either separate with a "," and/or "and."—
Reply to this email directly or view it on GitHub
https://github.com/ceph/ceph/pull/4172/files#r27429934.
Bug#: 2861 Previous changes were calling the function is_valid_name() multiple times. Made error display simpler. Signed-off-by: Rajesh Nambiar <rajesh.n@msystechnologies.com>
SUCCESS: the output of run-make-check.sh on centos-7 for 23d7184 is http://paste2.org/vvN3xf6E |
Updated the code. |
errno = 0; /* To distinguish success/failure after call (see man page) */ | ||
long long ret = strtoll(str, &endptr, base); | ||
|
||
if ((errno == ERANGE && (ret == LLONG_MAX || ret == LLONG_MIN)) | ||
|| (errno != 0 && ret == 0)) { | ||
ostringstream oss; | ||
oss << "strict_strtoll: integer underflow or overflow parsing '" << str << "'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should have just modified the message here and 3 other places.
Why get rid of the ostringstream that is working?
Bug # 2861 Signed off: Rajesh Nambiar <rajesh.n@msystechnologies.com>
Made it simpler. |
SUCCESS: the output of run-make-check.sh on centos-7 for 29ceedf is http://paste2.org/zv9nDDtp |
Let's add test cases for the scenarios that have been improved, at least those mentioned in the 2862 tracker bug. |
Someone else made conflicting changes. You'll have to rebase and resolve the conflicts. |
oss << "strict_strtoll: expected integer, got: '" << str << "'"; | ||
*err = oss.str(); | ||
errStr = "The option value '"; | ||
errStr.append(str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the original 'expected integer' can be pretty useful for things like pool vs poolid, which can get confused. I'd keep the specific error for this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, But I do feel from a end user's perspective these technical terms like "integer" may not make sense to him.Better may be to declare that option value is invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saying it's invalid gives no information about what a valid value would be, which seems useful to me for this case. The end user for the rbd cli tool is likely familiar with the word integer, since they're probably a storage admin/ops/dev rather than an end user of whatever service they're deploying ceph underneath.
I like the detailed and well-isolated commits. It'd be good to match the existing coding style - a few differences I notice:
|
Conflicts: src/common/ceph_argparse.cc src/rbd.cc
SUCCESS: the output of run-make-check.sh on centos-7 for bb449dd is http://paste2.org/I502c0vM |
Greetings. |
1) Reverted back changes related to name validation for Bug # 2861 due to utf 8 and compatibility issues. 2) Change in message in strtol.cc Signed Off: Rajesh Nambiar <rajesh.n@msystechnologies.com>
Josh, I have done the necessary changes please have a look. |
SUCCESS: the output of run-make-check.sh on centos-7 for e64808a is http://paste2.org/93W0h7v4 |
Thanks Rajesh, looks good! Could you squash the extra commits from review into the original 3? |
SUCCESS: the output of run-make-check.sh on centos-7 for d206384 is http://paste2.org/vbjXLp44 |
The rebase seems to be failing ubuntu@Host-CephAdmin: I did pick of the original 3 commits and squash of commits 0959204 however rebase fails with below error, the Checkin 6076233 is not [detached HEAD 4318acb] Fix to some of the command line parsing (including When you have resolved this problem run "git rebase --continue". ubuntu@Host-CephAdmin:~/Final/ceph$ git status Not currently on any branch.Changes to be committed:(use "git reset HEAD ..." to unstage)modified: configure.acmodified: m4/ax_arm.m4modified: src/arch/arm.cmodified: src/arch/arm.hmodified: src/common/Makefile.ammodified: src/common/crc32c.ccnew file: src/common/crc32c_aarch64.cnew file: src/common/crc32c_aarch64.hmodified: src/test/common/test_crc32c.ccmodified: src/test/test_arch.ccUnmerged paths:(use "git reset HEAD ..." to unstage)(use "git add/rm ..." as appropriate to mark resolution)added by us: src/gmockOn Tue, Apr 7, 2015 at 4:16 AM, Josh Durgin notifications@github.com
|
Sometimes it's easiest to reset --mixed and recreate the commits. I did that and pushed the result to wip-2862 in the ceph repo. I'll merge once it passes through testing. |
Looks like I messed the repository. I deleted that old one and created new On Wed, Apr 8, 2015 at 12:35 PM, Josh Durgin notifications@github.com
|
In case if you have already taken the changes then its great, else to avoid which contains all the needed changes. Rgds On Wed, Apr 8, 2015 at 12:35 PM, Josh Durgin notifications@github.com
|
The Changes are fix to Bug # 2862
There are 3 commits