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

rbd-nbd: fix generic option issue #17375

Merged
merged 2 commits into from Sep 6, 2017
Merged

rbd-nbd: fix generic option issue #17375

merged 2 commits into from Sep 6, 2017

Conversation

liupan1111
Copy link
Contributor

@liupan1111 liupan1111 commented Aug 30, 2017

This issue is introduced by #12433

I also changed the name of asok by adding nbd name, so that the user could easily get perf information.

Fixes: http://tracker.ceph.com/issues/20426
Signed-off-by: Pan Liu wanjun.lp@alibaba-inc.com

Signed-off-by: Pan Liu <wanjun.lp@alibaba-inc.com>
@liupan1111
Copy link
Contributor Author

@trociny please help take a look. I tried qa/workunits/rbd/rbd_nbd.sh and it works fine.

@liupan1111
Copy link
Contributor Author

retest This please

}

auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, code_env, env_flag);
g_ceph_context->_conf->set_val_or_die("pid_file", "");
Copy link
Contributor

Choose a reason for hiding this comment

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

@liupan1111 I am not very happy you returned global_init back to rbd_nbd, that is run for all commands. We had some reasons to call it for "map" command only: it made the code cleaner avoiding e.g. manual command line parsing as you added above to check if it is "map" command.

Actually, the problem is that parse_args, which has to filter out all ceph common options before parsing nbd specific options, does not filter out "-c" like options. These can be filtered out by ceph_argparse_early_args. So if you just add something like below at the beginning of parse_args:

std::string conf_file_list;
std::string cluster;
CephInitParameters iparams = ceph_argparse_early_args(
    args, CEPH_ENTITY_TYPE_CLIENT, &cluster, &conf_file_list);

I think it should fix the issue.

The only potential problem with not calling global_init for non "map" commands is that if someone specifies "-c" like option for such a command it will be just ignored. This may have undesirable effect e.g. if the user has different default pool specified in config, and then "list" command will output mapped with wrong default pool. Still I prefer this solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes! This method is much better. Thanks.

env_to_vec(args);

for (auto &temp_args : args) {
if (strcmp(temp_args, "map") == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We discussed issues with such manual parsing earlier. Consider a case when a user has a pool named "map" and specified --rbd-default-pool map in the command line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It thought about it, but I didn't think it is a bug:
For map command, the user must input "rbd-nbd map". Even for the case "--rbd-default-pool map", it should be "rbd-nbd map --rbd-default-pool map", so I don't think it will break anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for other command, such as unmap, list-mapped, no pool/image should be input.

@@ -655,6 +658,11 @@ static int do_map(int argc, const char *argv[], Config *cfg)
read_only = 1;
}

change_admin_socket(index);
Copy link
Contributor

Choose a reason for hiding this comment

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

We discussed this earlier too. After this change the users lost a possibility to change admin socket path via config. I like the idea to have "nbdX" in the socket name so actually I don't mind. But as far as I recall Jason did not like this idea and suggested to extend config implementation to support user defined (client specific) meta variables so we could use e.g. {nbd} meta variable in admin_socket config option.

@dillaman what do you think?

Choose a reason for hiding this comment

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

Indeed -- I don't want to take a step backwards and have rbd-nbd automagically override configuration settings. I think a plugable set of metavariables would be helpful in other scenarios as well (but that shouldn't be part of this PR).

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I think allowing users to override admin_socket is very important. Because now they can map images with a command like below:

rbd-nbd --admin-socket=/tmp/${image_name}.asok map ${image_name}

And would lose this possibility after your change. You could change your code to change admin socket only if it is not specified, then I would not mind, but I would like to see what Jason thinks.

Copy link
Contributor Author

@liupan1111 liupan1111 Sep 2, 2017

Choose a reason for hiding this comment

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

@trociny I think it is hard for the user to specify it:

  1. As you said, ${image_name}, but for now, we allow the user to map an image more than once in same client, and it is useful in our apps. So ${image_name} could not be used. I also consider pid, but also not workable, because in "do_map", main process will be forked.
  2. I used "nbdX" in our product, and the feedback from our customer is good.

I can understand your concern, you may want to give flexibility. I could remove this commit from this PR.

@liupan1111
Copy link
Contributor Author

@trociny updated, thanks.

@liupan1111
Copy link
Contributor Author

retest This please

@@ -917,6 +917,11 @@ static int do_list_mapped_devices()

static int parse_args(vector<const char*>& args, std::ostream *err_msg, Config *cfg)
{
std::string conf_file_list;
std::string cluster;
CephInitParameters iparams = ceph_argparse_early_args(

Choose a reason for hiding this comment

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

How we are using this local variable in this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@amitkumar50 thanks for comment. As @trociny said, I will use it later.

std::string conf_file_list;
std::string cluster;
CephInitParameters iparams = ceph_argparse_early_args(
args, CEPH_ENTITY_TYPE_CLIENT, &cluster, &conf_file_list);
Copy link
Contributor

Choose a reason for hiding this comment

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

@liupan1111 It would be nice to pass the results of ceph_argparse_early_args to config, i.e:

  1. set config.name = iparams.name
  2. set config.cluster = cluster
  3. if conf_file_list is not empty, pass it to config.parse_config_files instead of nullptr.

This should make "rbd_default_pool" config option to be used properly when it is changed in config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool!

@liupan1111
Copy link
Contributor Author

@trociny updated, please help take a look.

Copy link
Contributor

@trociny trociny left a comment

Choose a reason for hiding this comment

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

otherwise LGTM

std::string cluster;
CephInitParameters iparams = ceph_argparse_early_args(
args, CEPH_ENTITY_TYPE_CLIENT, &cluster, &conf_file_list);

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: unnecessary empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup

Fixes: http://tracker.ceph.com/issues/20426
Signed-off-by: Pan Liu <wanjun.lp@alibaba-inc.com>
@liupan1111
Copy link
Contributor Author

@trociny done.

@liupan1111
Copy link
Contributor Author

@trociny could this pr be merged? thanks.

@trociny trociny merged commit b1e9cab into ceph:master Sep 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants