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

FixForBug#2862 #4172

Closed
wants to merge 9 commits into from
Closed

FixForBug#2862 #4172

wants to merge 9 commits into from

Conversation

knrajnambiar76
Copy link

The Changes are fix to Bug # 2862

There are 3 commits

  1. One for rbd file ie rbd.cc
  2. Second commit groups various common files (ie strtol.cc and ceph_argparse.cc)
  3. third commit is for test case file pool.t

rajesh added 3 commits March 25, 2015 10:13
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>
@loic-bot
Copy link

SUCCESS: the output of run-make-check.sh on centos-7 for 0ceaea2 is http://paste2.org/1smy9n7I

:octocat: Sent from GH.

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>
@loic-bot
Copy link

SUCCESS: the output of run-make-check.sh on centos-7 for 41bdf90 is http://paste2.org/dNa5PMwt

:octocat: Sent from GH.

@knrajnambiar76
Copy link
Author

I have comited fix for Bug#2861 just now
This Pull request contains fix for Bug#2862 and 2861

@knrajnambiar76
Copy link
Author

Greetings!
Any feedback regarding the changes.

@@ -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)) {
Copy link
Contributor

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."

Copy link
Author

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>
@loic-bot
Copy link

SUCCESS: the output of run-make-check.sh on centos-7 for 23d7184 is http://paste2.org/vvN3xf6E

:octocat: Sent from GH.

@knrajnambiar76
Copy link
Author

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 << "'";
Copy link
Contributor

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>
@knrajnambiar76
Copy link
Author

Made it simpler.

@loic-bot
Copy link

loic-bot commented Apr 1, 2015

SUCCESS: the output of run-make-check.sh on centos-7 for 29ceedf is http://paste2.org/zv9nDDtp

:octocat: Sent from GH.

@dzafman
Copy link
Contributor

dzafman commented Apr 1, 2015

Let's add test cases for the scenarios that have been improved, at least those mentioned in the 2862 tracker bug.

@dzafman
Copy link
Contributor

dzafman commented Apr 1, 2015

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);
Copy link
Member

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

Copy link
Author

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.

Copy link
Member

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.

@jdurgin
Copy link
Member

jdurgin commented Apr 2, 2015

I like the detailed and well-isolated commits. It'd be good to match the existing coding style - a few differences I notice:

  • use underscores for var_names instead of camelCase
  • put a space between if and (
  • put spaces after commas, and around operators like <<
  • any if with an else clause where either part is multiple lines should have {} for both clauses
    The coding style guide is here: https://github.com/ceph/ceph/blob/master/CodingStyle

Conflicts:
	src/common/ceph_argparse.cc
	src/rbd.cc
@loic-bot
Copy link

loic-bot commented Apr 2, 2015

SUCCESS: the output of run-make-check.sh on centos-7 for bb449dd is http://paste2.org/I502c0vM

:octocat: Sent from GH.

@knrajnambiar76
Copy link
Author

Greetings.
I have Merged the changes and also updated the code as per Ceph Coding style. I have put my thoughts to the valuable comments which you have written. If some further changes are needed please let me know.
Regarding the addition of test case, within ceph/src/test/cli/rbd directory Iam seeing files "not-enough-args.t", "invalid-snap-usage.t" and "help.t" none of these are suppose to cover invalid argument cases. Which means there is need to add new file for checking invalid cases, However I am not able to figure out, to which file I need to make an entry so that particular new file gets executed along with other *.t files when build happens.

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>
@knrajnambiar76
Copy link
Author

Josh, I have done the necessary changes please have a look.

@loic-bot
Copy link

loic-bot commented Apr 3, 2015

SUCCESS: the output of run-make-check.sh on centos-7 for e64808a is http://paste2.org/93W0h7v4

:octocat: Sent from GH.

@jdurgin
Copy link
Member

jdurgin commented Apr 6, 2015

Thanks Rajesh, looks good! Could you squash the extra commits from review into the original 3?

@loic-bot
Copy link

loic-bot commented Apr 7, 2015

SUCCESS: the output of run-make-check.sh on centos-7 for d206384 is http://paste2.org/vbjXLp44

:octocat: Sent from GH.

@knrajnambiar76
Copy link
Author

The rebase seems to be failing

ubuntu@Host-CephAdmin:/Final/ceph$ git rebase -i HEAD15

I did pick of the original 3 commits and squash of commits 0959204
0959204
and 7b5e1ab
7b5e1ab
also removed commits 267bdc4
267bdc4,
96ed40d
96ed40d
and 9644601
9644601

however rebase fails with below error, the Checkin 6076233 is not
associated with me.

[detached HEAD 4318acb] Fix to some of the command line parsing (including
rbd)
2 files changed, 91 insertions(+), 19 deletions(-)
error: could not apply 6076233... crc32c: add aarch64 optimized crc32c
implementation

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".
Could not apply 6076233... crc32c: add aarch64 optimized crc32c
implementation

ubuntu@Host-CephAdmin:~/Final/ceph$ git status

Not currently on any branch.

Changes to be committed:

(use "git reset HEAD ..." to unstage)

modified: configure.ac

modified: m4/ax_arm.m4

modified: src/arch/arm.c

modified: src/arch/arm.h

modified: src/common/Makefile.am

modified: src/common/crc32c.cc

new file: src/common/crc32c_aarch64.c

new file: src/common/crc32c_aarch64.h

modified: src/test/common/test_crc32c.cc

modified: src/test/test_arch.cc

Unmerged paths:

(use "git reset HEAD ..." to unstage)

(use "git add/rm ..." as appropriate to mark resolution)

added by us: src/gmock

On Tue, Apr 7, 2015 at 4:16 AM, Josh Durgin notifications@github.com
wrote:

Thanks Rajesh, looks good! Could you squash the extra commits from review
into the original 3?


Reply to this email directly or view it on GitHub
#4172 (comment).

@jdurgin
Copy link
Member

jdurgin commented Apr 8, 2015

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.

@knrajnambiar76
Copy link
Author

Looks like I messed the repository. I deleted that old one and created new
one ( pull requst # 4299), it contains all the necessary changes.

On Wed, Apr 8, 2015 at 12:35 PM, Josh Durgin notifications@github.com
wrote:

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.


Reply to this email directly or view it on GitHub
#4172 (comment).

@knrajnambiar76
Copy link
Author

In case if you have already taken the changes then its great, else to avoid
confusion I created a new request
#4299

which contains all the needed changes.

Rgds
Rajesh

On Wed, Apr 8, 2015 at 12:35 PM, Josh Durgin notifications@github.com
wrote:

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.


Reply to this email directly or view it on GitHub
#4172 (comment).

@jdurgin jdurgin closed this Apr 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants