Project

General

Profile

Actions

Bug #49088

closed

cannot set --id/--name (and others) arguments via environment variable CEPH_ARGS

Added by Patrick Donnelly about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Urgent
Assignee:
-
Category:
-
Target version:
% Done:

0%

Source:
Development
Tags:
Backport:
pacific,octopus
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

This appears to be because ceph_argparse_early_args is not called from parse_env:

https://github.com/ceph/ceph/blob/caa58fce7a3c6a16d86ec2bf075a204e1e2b836c/src/common/config.cc#L591

So it's not possible to set --id or other common arguments via $CEPH_ARGS.

For context, the reason I want this is for libcephsqlite [1] which has no way to set the --id except through this environment variable.

[1] https://github.com/ceph/ceph/pull/39191

Actions #1

Updated by Sage Weil about 3 years ago

Just a note that you can set the id via the argument to libcephfs's ceph_create()...

Actions #2

Updated by Sage Weil about 3 years ago

Looking a bit further I don't think any other early arguments apply... -i is the only useful one, and that is passed in explicitly to ceph_create().

(Otherwise, a patch like this would fix it:

diff --git a/src/libcephfs.cc b/src/libcephfs.cc
index 261ee695499..d1c0130ea22 100644
--- a/src/libcephfs.cc
+++ b/src/libcephfs.cc
@@ -412,7 +412,16 @@ extern "C" int ceph_create_from_rados(struct ceph_mount_info **cmount,

 extern "C" int ceph_create(struct ceph_mount_info **cmount, const char * const id)
 {
-  CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT);
+  std::string cluster, conf_file_list;  // note: these are ignored
+  std::vector<const char*> env_args;
+  if (getenv("CEPH_ARGS")) {
+    env_to_vec(env_args, "CEPH_ARGS");
+  }
+  CephInitParameters iparams = ceph_argparse_early_args(
+    args,
+    CEPH_ENTITY_TYPE_CLIENT,
+    &cluster,
+    &conf_file_list);
   if (id) {
     iparams.name.set(CEPH_ENTITY_TYPE_CLIENT, id);
   }

)

Actions #3

Updated by Sage Weil about 3 years ago

  • Status changed from New to Need More Info
Actions #4

Updated by Patrick Donnelly about 3 years ago

Sage Weil wrote:

Just a note that you can set the id via the argument to libcephfs's ceph_create()...

This is for libcephsqlite not libcephfs. libcephsqlite may be loaded as an extension: https://sqlite.org/loadext.html

In that situation, it creates its own CephContext as a library: https://github.com/ceph/ceph/pull/39191/files#diff-ded8375ff66b37ff397079257b05404cba3936aac2f67dad1f98134d07a7f17bR119-R140

But it does not have access to argv. So the only way to set an --id is via $CEPH_ARGS (AFAIK).

Actions #5

Updated by Patrick Donnelly about 3 years ago

  • Status changed from Need More Info to Closed

Sage Weil wrote:

Looking a bit further I don't think any other early arguments apply... -i is the only useful one, and that is passed in explicitly to ceph_create().

(Otherwise, a patch like this would fix it:
[...]
)

I was able to try your patch and that resolves it. Thanks Sage!

Actions

Also available in: Atom PDF