]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
vstart: refactor and fix forced config changes 10312/head
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 8 Jul 2016 23:00:12 +0000 (19:00 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Sun, 24 Jul 2016 16:46:09 +0000 (12:46 -0400)
Despite using the -k option, vstart would sometimes (e.g. --smallmds) append
changes to the config file.  This commit runs all config changes through a
function which checks if the config file should be overwritten.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/vstart.sh

index 4d53bef41cadf970bbe6be09f54367050f04d29c..c5fc5c707d6aa8a406c038e1b0e07ab5ed1f131d 100755 (executable)
@@ -289,6 +289,8 @@ if [ "$overwrite_conf" -eq 0 ]; then
         CEPH_NUM_MDS="$MDS"
     RGW=`$CEPH_BIN/ceph-conf -c $conf_fn --name $VSTART_SEC num_rgw 2>/dev/null` && \
         CEPH_NUM_RGW="$RGW"
+else
+       rm -- "$conf_fn"
 fi
 
 if [ "$start_all" -eq 1 ]; then
@@ -327,6 +329,12 @@ run() {
     fi
 }
 
+wconf() {
+       if [ "$overwrite_conf" -eq 1 ]; then
+               cat >> "$conf_fn"
+       fi
+}
+
 if [ "$debug" -eq 0 ]; then
     CMONDEBUG='
        debug mon = 10
@@ -457,10 +465,8 @@ DAEMONOPTS="
 
 
 if [ "$start_mon" -eq 1 ]; then
-
        if [ "$new" -eq 1 ]; then
-               if [ $overwrite_conf -eq 1 ]; then
-                       cat <<EOF > $conf_fn
+        wconf <<EOF
 ; generated by vstart.sh on `date`
 [$VSTART_SEC]
         num mon = $CEPH_NUM_MON
@@ -488,28 +494,27 @@ if [ "$start_mon" -eq 1 ]; then
         run dir = $CEPH_OUT_DIR
         enable experimental unrecoverable data corrupting features = *
 EOF
-if [ "$lockdep" -eq 1 ] ; then
-cat <<EOF >> $conf_fn
+               if [ "$lockdep" -eq 1 ] ; then
+                       wconf <<EOF
         lockdep = true
 EOF
-fi
-if [ "$cephx" -eq 1 ] ; then
-cat <<EOF >> $conf_fn
+               fi
+               if [ "$cephx" -eq 1 ] ; then
+                       wconf <<EOF
         auth supported = cephx
 EOF
-else
-cat <<EOF >> $conf_fn
+               else
+                       wconf <<EOF
        auth cluster required = none
        auth service required = none
        auth client required = none
 EOF
-fi
-if [ "$short" -eq 1 ]; then
-    COSDSHORT="        osd max object name len = 460
+               fi
+               if [ "$short" -eq 1 ]; then
+                       COSDSHORT="        osd max object name len = 460
         osd max object namespace len = 64"
-fi
-                       cat <<EOF >> $conf_fn
-
+               fi
+               wconf <<EOF
 [client]
         keyring = $keyring_fn
         log file = $CEPH_OUT_DIR/\$name.\$pid.log
@@ -566,8 +571,6 @@ $extra_conf
 [global]
 $extra_conf
 EOF
-               fi
-
                if [ `echo $IP | grep '^127\\.'` ]
                then
                        echo
@@ -590,14 +593,12 @@ EOF
                for f in $MONS
                do
                        str="$str --add $f $IP:$(($CEPH_PORT+$count))"
-                       if [ $overwrite_conf -eq 1 ]; then
-                               cat <<EOF >> $conf_fn
+                       wconf <<EOF
 [mon.$f]
         host = $HOSTNAME
         mon data = $CEPH_DEV_DIR/mon.$f
         mon addr = $IP:$(($CEPH_PORT+$count))
 EOF
-                       fi
                        count=$(($count + 1))
                done
                prun "$CEPH_BIN/monmaptool" --create --clobber $str --print "$monmap_fn"
@@ -626,12 +627,10 @@ if [ "$start_osd" -eq 1 ]; then
     for osd in `seq 0 $((CEPH_NUM_OSD-1))`
     do
        if [ "$new" -eq 1 ]; then
-           if [ $overwrite_conf -eq 1 ]; then
-                   cat <<EOF >> $conf_fn
+               wconf <<EOF
 [osd.$osd]
         host = $HOSTNAME
 EOF
-           fi
 
            rm -rf $CEPH_DEV_DIR/osd$osd || true
            for f in $CEPH_DEV_DIR/osd$osd/*; do btrfs sub delete $f &> /dev/null || true; done
@@ -654,7 +653,7 @@ fi
 
 # mds
 if [ "$smallmds" -eq 1 ]; then
-    cat <<EOF >> $conf_fn
+    wconf <<EOF
 [mds]
        mds log max segments = 2
        mds cache size = 10000
@@ -682,20 +681,18 @@ if [ "$start_mds" -eq 1 -a "$CEPH_NUM_MDS" -gt 0 ]; then
        if [ "$new" -eq 1 ]; then
            prun mkdir -p "$CEPH_DEV_DIR/mds.$name"
            key_fn=$CEPH_DEV_DIR/mds.$name/keyring
-           if [ $overwrite_conf -eq 1 ]; then
-           cat <<EOF >> $conf_fn
+           wconf <<EOF
 [mds.$name]
         host = $HOSTNAME
 EOF
                if [ "$standby" -eq 1 ]; then
                    mkdir -p $CEPH_DEV_DIR/mds.${name}s
-                   cat <<EOF >> $conf_fn
+                       wconf <<EOF
        mds standby for rank = $mds
 [mds.${name}s]
         mds standby replay = true
         mds standby for name = ${name}
 EOF
-               fi
            fi
            prun $SUDO "$CEPH_BIN/ceph-authtool" --create-keyring --gen-key --name="mds.$name" "$key_fn"
            ceph_adm -i "$key_fn" auth add "mds.$name" mon 'allow profile mds' osd 'allow *' mds 'allow'