From fa0bd06b4657e5b84e237b76033ac3d3478b6a1f Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Fri, 3 Oct 2014 14:08:57 +0200 Subject: [PATCH] ceph-disk: bootstrap-osd keyring ignores --statedir The STATEDIR variable is used to initialize the bootstrap-osd keyring before it gets a chance to be overriden by --statedir. Replace it with {statedir} so that it can be substituted after all options have been parsed. http://tracker.ceph.com/issues/9653 Fixes: #9653 Signed-off-by: Loic Dachary --- src/ceph-disk | 9 +++++---- src/test/ceph-disk.sh | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ceph-disk b/src/ceph-disk index 8475c56811657..90f706ff98134 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -1919,7 +1919,8 @@ def activate( raise Error('No OSD uuid assigned.') LOG.debug('OSD uuid is %s', fsid) - keyring = activate_key_template.format(cluster=cluster) + keyring = activate_key_template.format(cluster=cluster, + statedir=STATEDIR) osd_id = get_osd_id(path) if osd_id is None: @@ -2658,7 +2659,7 @@ def parse_args(): help='path to block device or directory', ) activate_parser.set_defaults( - activate_key_template=STATEDIR + '/bootstrap-osd/{cluster}.keyring', + activate_key_template='{statedir}/bootstrap-osd/{cluster}.keyring', func=main_activate, ) @@ -2682,7 +2683,7 @@ def parse_args(): choices=INIT_SYSTEMS, ) activate_journal_parser.set_defaults( - activate_key_template=STATEDIR + '/bootstrap-osd/{cluster}.keyring', + activate_key_template='{statedir}/bootstrap-osd/{cluster}.keyring', func=main_activate_journal, ) @@ -2701,7 +2702,7 @@ def parse_args(): choices=INIT_SYSTEMS, ) activate_all_parser.set_defaults( - activate_key_template=STATEDIR + '/bootstrap-osd/{cluster}.keyring', + activate_key_template='{statedir}/bootstrap-osd/{cluster}.keyring', func=main_activate_all, ) diff --git a/src/test/ceph-disk.sh b/src/test/ceph-disk.sh index bdd705b4b90b0..3bfbbf45c7abe 100755 --- a/src/test/ceph-disk.sh +++ b/src/test/ceph-disk.sh @@ -218,6 +218,12 @@ function test_find_cluster_by_uuid() { teardown } +# http://tracker.ceph.com/issues/9653 +function test_keyring_path() { + test_activate_dir 2>&1 | tee $DIR/test_keyring + grep --quiet "keyring $DIR/bootstrap-osd/ceph.keyring" $DIR/test_keyring || return 1 +} + function run() { local default_actions default_actions+="test_path " @@ -226,6 +232,7 @@ function run() { default_actions+="test_prepend_to_path " default_actions+="test_activate_dir_magic " default_actions+="test_activate_dir " + default_actions+="test_keyring_path " local actions=${@:-$default_actions} for action in $actions ; do setup -- 2.39.5