Commit 0214b0c0 authored by Iustin Pop's avatar Iustin Pop
Browse files

Make ganeti-noded create BDEV_CACHE_DIR automatically

Currently in order to deal with tmpfs /var/run, we create the
BDEV_CACHE_DIR in the init script. However, that does not cover all the
cases, and it's not a proper place to deal with it: for example, dealing
with not initialized clusters and the master node is more complicated.

Therefore, this patch does:
  - make ganeti-noded create the directory automatically
  - make ganeti-noded error out if it can't create it or it's already
    there but not a directory
  - remove the creation from the init.d script

Reviewed-by: ultrotter
parent fff33d70
......@@ -30,6 +30,7 @@ import resource
import traceback
import BaseHTTPServer
import simplejson
import errno
from optparse import OptionParser
......@@ -536,6 +537,21 @@ def main():
print "Cluster configuration incomplete: '%s'" % str(err)
sys.exit(5)
# create /var/run/ganeti if not existing, in order to take care of
# tmpfs /var/run
if not os.path.exists(constants.BDEV_CACHE_DIR):
try:
os.mkdir(constants.BDEV_CACHE_DIR, 0755)
except EnvironmentError, err:
if err.errno != errno.EEXIST:
print ("Node setup wrong, cannot create directory %s: %s" %
(constants.BDEV_CACHE_DIR, err))
sys.exit(5)
if not os.path.isdir(constants.BDEV_CACHE_DIR):
print ("Node setup wrong, %s is not a directory" %
constants.BDEV_CACHE_DIR)
sys.exit(5)
# become a daemon
if options.fork:
createDaemon()
......
......@@ -17,7 +17,6 @@ NAME=ganeti-noded
NODED=@PREFIX@/sbin/ganeti-noded
MASTER=@PREFIX@/sbin/ganeti-master
SCRIPTNAME=@SYSCONFDIR@/init.d/ganeti
RUNDIR="@LOCALSTATEDIR@/run/ganeti"
test -f $NODED || exit 0
......@@ -56,7 +55,6 @@ case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
check_config
test -e "$RUNDIR" || mkdir -p "$RUNDIR"
if start-stop-daemon --start --quiet --exec $NODED; then
log_end_msg 0
else
......@@ -90,5 +88,3 @@ case "$1" in
esac
exit 0
# vim: set sw=4 sts=4 et foldmethod=marker :
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment