Project

General

Profile

Actions

Bug #3001

closed

mkcephfs: -a fails if only "host=localhost" sections seen in ceph.conf

Added by Anonymous over 11 years ago. Updated over 11 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
% Done:

0%

Source:
Community (user)
Tags:
Backport:
Regression:
Severity:
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

This was reported earlier on the list as http://thread.gmane.org/gmane.comp.file-systems.ceph.devel/8051/focus=8092 and now John ran into it too.

The relevant hint is this:

cat: /tmp/mkcephfs.MCBIHvn4Ru/key.*: No such file or directory

which says that no daemons generated those key.* entries. Reading through mkcephfs, I see

if [ -n "$initlocaldaemons" ]; then
    get_name_list "$initlocaldaemons" 
    for name in $what; do
    type=`echo $name | cut -c 1-3`   # e.g. 'mon', if $name is 'mon1'
    id=`echo $name | cut -c 4- | sed 's/^\\.//'`
    num=$id
    name="$type.$id" 

    check_host || continue

    $0 -d $dir --init-daemon $name    
    done
    exit 0
fi

where check_host is defined as

check_host() {
    # what host is this daemon assigned to?
    host=`$CCONF -c $conf -n $type.$id host`
    [ "$host" = "localhost" ] && host="" 
    ...
    # ignore all sections without 'host' defined
    if [ -z "$host" ]; then
    return 1
    ...

and noticing that both Tim and John had "host = localhost" all over their ceph.conf, leads to..

- check_host is going to skip all those host=localhost sections
- thus, no key.* files are created
- the glob does not expand, is literally "key.*"
- cat sees no "key.*" file and fails
- set -e makes the script abort

I'm not 100% sure how this should be fixed.

- should check_host process the host=localhost entries? (what side effects will this have?)
- should the for loop be converted from globs to find, so it handles no matches properly? (that still won't make the cluster work!)

set -x output from John appended:

john@admin-host:/etc/ceph$ sudo mkcephfs -a -c /etc/ceph/ceph.conf -k ceph.keyring
temp dir is /tmp/mkcephfs.MCBIHvn4Ru
preparing monmap in /tmp/mkcephfs.MCBIHvn4Ru/monmap
/usr/bin/monmaptool --create --clobber --add a 127.0.0.1:6789 --print /tmp/mkcephfs.MCBIHvn4Ru/monmap
/usr/bin/monmaptool: monmap file /tmp/mkcephfs.MCBIHvn4Ru/monmap
/usr/bin/monmaptool: generated fsid bada2755-549f-48f6-8b26-7c0a22f8e379
epoch 0
fsid bada2755-549f-48f6-8b26-7c0a22f8e379
last_changed 2012-08-20 14:51:54.973357
created 2012-08-20 14:51:54.973357
0: 127.0.0.1:6789/0 mon.a
/usr/bin/monmaptool: writing epoch 0 to /tmp/mkcephfs.MCBIHvn4Ru/monmap (1 monitors)
Building generic osdmap from /tmp/mkcephfs.MCBIHvn4Ru/conf
/usr/bin/osdmaptool: osdmap file '/tmp/mkcephfs.MCBIHvn4Ru/osdmap'
/usr/bin/osdmaptool: writing epoch 1 to /tmp/mkcephfs.MCBIHvn4Ru/osdmap
Generating admin key at /tmp/mkcephfs.MCBIHvn4Ru/keyring.admin
creating /tmp/mkcephfs.MCBIHvn4Ru/keyring.admin
Building initial monitor keyring
cat: /tmp/mkcephfs.MCBIHvn4Ru/key.*: No such file or directory
john@admin-host:/etc/ceph$ sudo sh -x /sbin/mkcephfs -a -c /etc/ceph/ceph.conf -k ceph.keyring
+ set -e
+ dirname /sbin/mkcephfs
+ [ /sbin = . ]
+ BINDIR=/usr/bin
+ LIBDIR=/usr/lib/ceph
+ ETCDIR=/etc/ceph
+ . /usr/lib/ceph/ceph_common.sh
+ CCONF=/usr/bin/ceph-conf
+ default_conf=/etc/ceph/ceph.conf
+ conf=/etc/ceph/ceph.conf
+ hostname+ 
cut -d . -f 1
+ hostname=admin-host
+ allhosts=0
+ mkbtrfs=0
+ preparemonmap=0
+ prepareosdfs=
+ initdaemon=
+ initdaemons=
+ preparemon=0
+ numosd=
+ useosdmap=
+ usecrushmapsrc=
+ usecrushmap=
+ verbose=0
+ adminkeyring=
+ conf=
+ dir=
+ moreargs=
+ auto_action=0
+ manual_action=0
+ nocopyconf=0
+ [ 5 -ge 1 ]
+ allhosts=1
+ auto_action=1
+ shift
+ [ 4 -ge 1 ]
+ [ -z /etc/ceph/ceph.conf ]
+ shift
+ conf=/etc/ceph/ceph.conf
+ shift
+ [ 2 -ge 1 ]
+ [ -z ceph.keyring ]
+ shift
+ adminkeyring=ceph.keyring
+ shift
+ [ 0 -ge 1 ]
+ [ -z /etc/ceph/ceph.conf ]
+ [ 0 -eq 0 ]
+ [ 1 -eq 0 ]
+ [ 0 -eq 1 ]
+ [ -n  ]
+ [ -n  ]
+ [ -n  ]
+ [ 0 -eq 1 ]
+ [ 1 -eq 1 ]
+ verify_conf
+ [ -x /etc/ceph/fetch_config ]
+ [ ! -e /etc/ceph/ceph.conf ]
+ [ -z  ]
+ mktemp -d -t mkcephfs.XXXXXXXXXX
+ dir=/tmp/mkcephfs.L9RBirZz4a
+ echo temp dir is /tmp/mkcephfs.L9RBirZz4a
temp dir is /tmp/mkcephfs.L9RBirZz4a
+ trap rm -rf /tmp/mkcephfs.L9RBirZz4a ; exit INT TERM EXIT
+ /sbin/mkcephfs --prepare-monmap -d /tmp/mkcephfs.L9RBirZz4a -c /etc/ceph/ceph.conf
preparing monmap in /tmp/mkcephfs.L9RBirZz4a/monmap
/usr/bin/monmaptool --create --clobber --add a 127.0.0.1:6789 --print /tmp/mkcephfs.L9RBirZz4a/monmap
/usr/bin/monmaptool: monmap file /tmp/mkcephfs.L9RBirZz4a/monmap
/usr/bin/monmaptool: generated fsid c25fbf4b-f839-47c5-bde3-56845ddae6bb
epoch 0
fsid c25fbf4b-f839-47c5-bde3-56845ddae6bb
last_changed 2012-08-20 14:53:33.110190
created 2012-08-20 14:53:33.110190
0: 127.0.0.1:6789/0 mon.a
/usr/bin/monmaptool: writing epoch 0 to /tmp/mkcephfs.L9RBirZz4a/monmap (1 monitors)
+ get_name_list osd mds
+ orig=osd mds
+ [ -z osd mds ]
+ what=
+ echo osd+ 
cut -c 1-3
+ type=osd
+ echo osd
+ cut+  -c 4-
sed s/\.//
+ id=
+ /usr/bin/ceph-conf -c /etc/ceph/ceph.conf -l osd
+ egrep -v ^osd$
+ all=osd.0
osd.1
+ what= osd.0
osd.1
+ echo mds
+ cut -c 1-3
+ type=mds
+ echo mds
+ sed s/\.//
+ cut -c 4-
+ id=
+ /usr/bin/ceph-conf -c /etc/ceph/ceph.conf -l mds
+ egrep -v ^mds$
+ all=mds.a
+ what= osd.0
osd.1 mds.a
+ echo osd.0
+ cut -c 1-3
+ type=osd
+ echo osd.0
+ cut -c 4-
+ sed s/^\.//
+ id=0
+ num=0
+ name=osd.0
+ check_host
+ /usr/bin/ceph-conf -c /etc/ceph/ceph.conf -n osd.0 host
+ host=localhost
+ [ localhost = localhost ]
+ host=
+ ssh=
+ rootssh=
+ sshdir=/etc/ceph
+ get_conf user  user
+ var=user
+ def=
+ key=user
+ shift
+ shift
+ shift
+ [ -z  ]
+ [ 0 -eq 1 ]
+ /usr/bin/ceph-conf -c /etc/ceph/ceph.conf -n osd.0 user
+ eval echo -n 
+ echo -n
+ eval user="" 
+ user=
+ [ -z  ]
+ return 1
+ continue
+ echo osd.1
+ cut -c 1-3
+ type=osd
+ echo osd.1
+ cut -c 4-
+ sed s/^\.//
+ id=1
+ num=1
+ name=osd.1
+ check_host
+ /usr/bin/ceph-conf -c /etc/ceph/ceph.conf -n osd.1 host
+ host=localhost
+ [ localhost = localhost ]
+ host=
+ ssh=
+ rootssh=
+ sshdir=/etc/ceph
+ get_conf user  user
+ var=user
+ def=
+ key=user
+ shift
+ shift
+ shift
+ [ -z  ]
+ [ 0 -eq 1 ]
+ /usr/bin/ceph-conf -c /etc/ceph/ceph.conf -n osd.1 user
+ eval echo -n 
+ echo -n
+ eval user="" 
+ user=
+ [ -z  ]
+ return 1
+ continue
+ echo mds.a
+ cut -c 1-3
+ type=mds
+ echo mds.a
+ cut+ sed s/^\.//
 -c 4-
+ id=a
+ num=a
+ name=mds.a
+ check_host
+ /usr/bin/ceph-conf -c /etc/ceph/ceph.conf -n mds.a host
+ host=localhost
+ [ localhost = localhost ]
+ host=
+ ssh=
+ rootssh=
+ sshdir=/etc/ceph
+ get_conf user  user
+ var=user
+ def=
+ key=user
+ shift
+ shift
+ shift
+ [ -z  ]
+ [ 0 -eq 1 ]
+ /usr/bin/ceph-conf -c /etc/ceph/ceph.conf -n mds.a user
+ eval echo -n 
+ echo -n
+ eval user="" 
+ user=
+ [ -z  ]
+ return 1
+ continue
+ /sbin/mkcephfs -d /tmp/mkcephfs.L9RBirZz4a --prepare-mon
Building generic osdmap from /tmp/mkcephfs.L9RBirZz4a/conf
/usr/bin/osdmaptool: osdmap file '/tmp/mkcephfs.L9RBirZz4a/osdmap'
/usr/bin/osdmaptool: writing epoch 1 to /tmp/mkcephfs.L9RBirZz4a/osdmap
Generating admin key at /tmp/mkcephfs.L9RBirZz4a/keyring.admin
creating /tmp/mkcephfs.L9RBirZz4a/keyring.admin
Building initial monitor keyring
cat: /tmp/mkcephfs.L9RBirZz4a/key.*: No such file or directory
+ rm -rf /tmp/mkcephfs.L9RBirZz4a
+ exit
john@admin-host:/etc/ceph$ 

Actions #1

Updated by Anonymous over 11 years ago

And for the record, for now I'm recommending this: don't use "host=localhost", put in the actual host name.

Actions #2

Updated by Anonymous over 11 years ago

  • Status changed from New to Resolved

commit 6a9bcc09a36e25f4e48994e9760b0d39f74b1bde
Author: Tommi Virtanen <tv@inktank.com>
Date:   2012-08-20 17:06:09 -0700

    mkcephfs, init-ceph: Warn if hostname "localhost" is seen in ceph.conf.

    Given a ceph.conf that looks like

      [osd.42]
      host = localhost

    mkcephfs used to exit with an obscure error message:

      cat: /tmp/mkcephfs.MCBIHvn4Ru/key.*: No such file or directory

    "localhost" was never intended to be a valid hostname to use there.
    Warn if we see it, and skip the entry. You should use the proper short
    hostname of the box.

    As init-ceph and mkcephfs share this library, this change affects the
    sysvinit scripts too. The behavior *shouldn't* change there (localhost
    entries were ignored earlier, too), but you may see this extra
    warning. Which is good.

    Closes: #3001
    Signed-off-by: Tommi Virtanen <tv@inktank.com>

diff --git a/src/ceph_common.sh b/src/ceph_common.sh
index 62c28ff..73f13f4 100644
--- a/src/ceph_common.sh
+++ b/src/ceph_common.sh
@@ -34,7 +34,10 @@ verify_conf() {
 check_host() {
     # what host is this daemon assigned to?
     host=`$CCONF -c $conf -n $type.$id host`
-    [ "$host" = "localhost" ] && host="" 
+    if [ "$host" = "localhost" ]; then
+       echo "$0: use a proper short hostname, not 'localhost', in $conf section $type.$id; skipping entry" 
+       return 1
+    fi
     ssh="" 
     rootssh="" 
     sshdir=$PWD
Actions

Also available in: Atom PDF