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

mon/OSDMonitor.cc: fix expected_num_objects interpret error #19651

Merged
merged 1 commit into from Jan 26, 2018
Merged

mon/OSDMonitor.cc: fix expected_num_objects interpret error #19651

merged 1 commit into from Jan 26, 2018

Conversation

yanghonggang
Copy link
Contributor

Copy link
Member

@jecluis jecluis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request also requires tests.

@@ -10154,6 +10155,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
}

bool implicit_rule_creation = false;
int64_t expected_num_objects = int64_t(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can simply be = 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -10193,6 +10195,10 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
}
} else {
//NOTE:for replicated pool,cmd_map will put rule_name to erasure_code_profile field
// and put expected_num_objects to ruleset field
if (rule_name != "") {
expected_num_objects = std::atoll(rule_name.c_str());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should be able to get the value with cmd_getval().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As 'rule' is stored as string, we can not get its value as a int64_t type with cmd_getval.
And rule already stored the string, so we only need to convert it to int64_t.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. Please use strict_strtoll() as is used in other parts of OSDMonitor.cc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@yanghonggang
Copy link
Contributor Author

@jecluis all done, please help to review

@yanghonggang
Copy link
Contributor Author

ping @jecluis

Copy link
Member

@jecluis jecluis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -54,5 +54,27 @@ function TEST_pool_create() {
ceph osd crush rule rm $rulename
}

function TEST_pool_create_rep_expected_num_objects() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you move this test to qa/standalone/mon/osd-pool-create.sh, so we can prevent "make check" from bloating over time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@yanghonggang
Copy link
Contributor Author

@tchaikov done

@@ -10207,8 +10218,10 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
goto reply;
}

int64_t expected_num_objects;
cmd_getval(cct, cmdmap, "expected_num_objects", expected_num_objects, int64_t(0));
if (expected_num_objects == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think it would be better to move this block into the erasure branch, i.e. right after https://github.com/ceph/ceph/pull/19651/files#diff-0a5db46a44ae9900e226289a810f10e8L10193 ? it's more symmetric this way, IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tchaikov okay

@yanghonggang
Copy link
Contributor Author

@tchaikov done

@yuriw
Copy link
Contributor

yuriw commented Jan 10, 2018

err = -EINVAL;
goto reply;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work. For example,

2018-01-12 03:30:18.208 7f08b542c700  1 -- 172.21.15.182:0/4125772450 --> 172.21.15.182:6789/0 -- mon_command({"format": "json", "rule": "by-host-smithi182", "pool_type": "replicated", "prefix": "osd pool create", "pg_num": "128", "erasure_code_profile": "by-host-smithi182", "pool": "by-host-smithi182"} v 0) v1 -- 
0x55b9e857ff80 con 0
2018-01-12 03:30:18.212 7f08bbf29700  1 -- 172.21.15.182:0/f5ea4aa2 <== mon.0 172.21.15.182:6789/0 11 ==== mon_command_ack([{"format": "json", "rule": "by-host-smithi182", "pool_type": "replicated", "prefix": "osd pool create", "pg_num": "128", "erasure_code_profile": "by-host-smithi182", "pool": "by-host-smithi182
"}]=ffffffea error parsing integer value 'by-host-smithi182': Expected option value to be integer, got 'by-host-smithi182' v10) v1 ==== 151+0+0 (883dec20 0 0) 0x55b9e857ff80 con 0x55b9e845a700

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liewegas
I can reproduce your problem through 'ceph -c ceph.conf osd pool create by-host-smithi182 128 replicated by-host-smithi182 by-host-smithi182'.
The expected format of this command is 'ceph osd pool create {pool-name} {pg-num} [{pgp-num}] [replicated] [crush-rule-name] [expected-num-objects]'.
So the last 'by-host-smithi182' is parsed as 'expected-num-objects'.
All behaviours are expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the command isnt coming from the CLI, it's the localpool mgr module, and it's sending well-formed JSON. We need to make OSDMonitor handle a well-formed command.

(The weird positional CLI parsing is super-lame, but it is what we have right now. We should avoid breaking the JSON in order to fix the CLI...)

Fixes: http://tracker.ceph.com/issues/22530
Signed-off-by: Yang Honggang <joseph.yang@xtaotech.com>
@yanghonggang
Copy link
Contributor Author

@liewegas 'erasure_code_profile' can be used as a flag, to indicate whether cmd is well formed.
if it's not empty, cmd is from CLI, else its well formed. what's your suggestion?

@yanghonggang
Copy link
Contributor Author

@liewegas please help to review

Copy link
Member

@liewegas liewegas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, thanks!

@tchaikov tchaikov merged commit 4233cc0 into ceph:master Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants