Commit 5c566e17 authored by Michael Hanselmann's avatar Michael Hanselmann

Merge branch 'next' into branch-2.1

* next:
  Add script to clean archived jobs after 21 days
  rapi: export more static node information
  Pass the correct signal to handlers
  cli: Use ToStdout/ToStderr instead of print
  Fix small typo in gnt-node
  Simplify handling of boolean args in rapi
  Fix checks in LUSetNodeParms for the master node
  Improve the example startup script
  Fix insserv dependencies

Conflicts:
	Makefile.am: added ganeti-cleaner
	doc/examples/ganeti.initd.in: Iustin's init script improvements
	lib/cli.py: Trivial (ToStderr changes)
parents a52ba89d fc3fd894
......@@ -27,6 +27,9 @@
/*.tar.bz2
/*.tar.gz
# daemons
/daemons/ganeti-cleaner
# devel
/devel/clean-cluster
/devel/upload
......
......@@ -50,6 +50,7 @@ maintainer-clean-local:
CLEANFILES = \
autotools/replace_vars.sed \
daemons/ganeti-cleaner \
devel/upload \
doc/examples/bash_completion \
doc/examples/ganeti.initd \
......@@ -172,6 +173,9 @@ dist_sbin_SCRIPTS = \
daemons/ganeti-rapi \
$(gnt_scripts)
nodist_sbin_SCRIPTS = \
daemons/ganeti-cleaner
dist_tools_SCRIPTS = \
tools/burnin \
tools/cfgshell \
......@@ -186,6 +190,7 @@ EXTRA_DIST = \
autotools/build-bash-completion \
autotools/docbook-wrapper \
autotools/run-in-tempdir \
daemons/ganeti-cleaner.in \
devel/upload.in \
$(docdot) \
$(docrst) \
......@@ -275,6 +280,11 @@ devel/upload: devel/upload.in stamp-directories $(REPLACE_VARS_SED)
sed -f $(REPLACE_VARS_SED) < $< > $@
chmod u+x $@
daemons/ganeti-cleaner: daemons/ganeti-cleaner.in stamp-directories \
$(REPLACE_VARS_SED)
sed -f $(REPLACE_VARS_SED) < $< > $@
chmod +x $@
doc/examples/%: doc/examples/%.in stamp-directories \
$(REPLACE_VARS_SED)
sed -f $(REPLACE_VARS_SED) < $< > $@
......
#!/bin/bash
#
# Copyright (C) 2009 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
set -e
DATA_DIR=@LOCALSTATEDIR@/lib/ganeti
QUEUE_ARCHIVE_DIR=$DATA_DIR/queue/archive
# Define how many days archived jobs should be left alone
REMOVE_AFTER=21
# Exit if machine is not part of a cluster
[[ -e $DATA_DIR/ssconf_master_node ]] || echo 0
# Exit if queue archive directory doesn't exist
[[ -d $QUEUE_ARCHIVE_DIR ]] || exit 0
# Remove old jobs
find $QUEUE_ARCHIVE_DIR -mindepth 2 -type f -mtime +$REMOVE_AFTER -print0 | \
xargs -r0 rm -f
exit 0
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
# restart failed instances
# Restart failed instances (every 5 minutes)
*/5 * * * * root [ -x @SBINDIR@/ganeti-watcher ] && @SBINDIR@/ganeti-watcher
# Clean job archive (at 01:45 AM)
45 1 * * * root [ -x @SBINDIR@/ganeti-cleaner ] && @SBINDIR@/ganeti-cleaner
......@@ -3,12 +3,12 @@
# based on skeleton from Debian GNU/Linux
### BEGIN INIT INFO
# Provides: ganeti
# Required-Start: $syslog $remote_fs xend
# Required-Stop: $syslog $remote_fs xend
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Ganeti Xen Cluster Manager
# Description: Ganeti Xen Cluster Manager
# Short-Description: Ganeti Cluster Manager
# Description: Ganeti Cluster Manager
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
......@@ -18,29 +18,21 @@ GANETIRUNDIR="@LOCALSTATEDIR@/run/ganeti"
GANETI_DEFAULTS_FILE="@SYSCONFDIR@/default/ganeti"
NODED_NAME="ganeti-noded"
NODED="@PREFIX@/sbin/${NODED_NAME}"
NODED_PID="${GANETIRUNDIR}/${NODED_NAME}.pid"
NODED="ganeti-noded"
NODED_ARGS=""
MASTERD_NAME="ganeti-masterd"
MASTERD="@PREFIX@/sbin/${MASTERD_NAME}"
MASTERD_PID="${GANETIRUNDIR}/${MASTERD_NAME}.pid"
MASTERD="ganeti-masterd"
MASTERD_ARGS=""
CONFD_NAME="ganeti-confd"
CONFD="@PREFIX@/sbin/${CONFD_NAME}"
CONFD_PID="${GANETIRUNDIR}/${CONFD_NAME}.pid"
CONFD="ganeti-confd"
CONFD_ARGS=""
RAPI_NAME="ganeti-rapi"
RAPI="@PREFIX@/sbin/${RAPI_NAME}"
RAPI_PID="${GANETIRUNDIR}/${RAPI_NAME}.pid"
RAPI="ganeti-rapi"
RAPI_ARGS=""
SCRIPTNAME="@SYSCONFDIR@/init.d/ganeti"
test -f $NODED || exit 0
test -f "@PREFIX@/sbin/$NODED" || exit 0
. /lib/lsb/init-functions
......@@ -76,51 +68,69 @@ check_exitcode() {
}
start_action() {
# called as start_action daemon pidfile
# called as start_action daemon-name
local daemon="$1"; shift
local pidfile="$1"; shift
log_action_begin_msg "$daemon"
start-stop-daemon --start --quiet --exec "$daemon" --pidfile "$pidfile" \
start-stop-daemon --start --quiet \
--pidfile "${GANETIRUNDIR}/${daemon}.pid" \
--startas "@PREFIX@/sbin/$daemon" \
--oknodo \
-- "$@"
check_exitcode $?
}
stop_action() {
# called as stop_action daemon pidfile
log_action_begin_msg "$1"
# called as stop_action daemon-name
local daemon="$1"
log_action_begin_msg "$daemon"
start-stop-daemon --stop --quiet --oknodo \
--retry 30 --pidfile "$2"
--retry 30 --pidfile "${GANETIRUNDIR}/${daemon}.pid"
check_exitcode $?
}
maybe_do() {
requested="$1"; shift
action="$1"; shift
target="$1"
if [ -z "$requested" -o "$requested" = "$target" ]; then
$action "$@"
fi
}
if [ -n "$2" -a \
"$2" != "$NODED" -a \
"$2" != "$MASTERD" -a \
"$2" != "$RAPI" ]; then
log_failure_msg "Unknown daemon '$2' requested"
exit 1
fi
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
log_daemon_msg "Starting $DESC" "$2"
check_config
start_action $NODED $NODED_PID $NODED_ARGS
start_action $MASTERD $MASTERD_PID $MASTERD_ARGS
start_action $CONFD $CONFD_PID $CONFD_ARGS
start_action $RAPI $RAPI_PID $RAPI_ARGS
maybe_do "$2" start_action $NODED $NODED_ARGS
maybe_do "$2" start_action $MASTERD $MASTERD_ARGS
maybe_do "$2" start_action $CONFD $CONFD_ARGS
maybe_do "$2" start_action $RAPI $RAPI_ARGS
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
stop_action $RAPI $RAPI_PID
stop_action $MASTERD $MASTERD_PID
stop_action $CONFD $CONFD_PID
stop_action $NODED $NODED_PID
log_daemon_msg "Stopping $DESC" "$2"
maybe_do "$2" stop_action $RAPI
maybe_do "$2" stop_action $CONFD
maybe_do "$2" stop_action $MASTERD
maybe_do "$2" stop_action $NODED
;;
restart|force-reload)
log_daemon_msg "Reloading $DESC"
stop_action $RAPI $RAPI_PID
stop_action $MASTERD $MASTERD_PID
stop_action $CONFD $CONFD_PID
stop_action $NODED $NODED_PID
maybe_do "$2" stop_action $RAPI
maybe_do "$2" stop_action $CONFD
maybe_do "$2" stop_action $MASTERD
maybe_do "$2" stop_action $NODED
check_config
start_action $NODED $NODED_PID $NODED_ARGS
start_action $MASTERD $MASTERD_PID $MASTERD_ARGS
start_action $CONFD $CONFD_PID $CONFD_ARGS
start_action $RAPI $RAPI_PID $RAPI_ARGS
maybe_do "$2" start_action $NODED $NODED_ARGS
maybe_do "$2" start_action $MASTERD $MASTERD_ARGS
maybe_do "$2" start_action $CONFD $CONFD_ARGS
maybe_do "$2" start_action $RAPI $RAPI_ARGS
;;
*)
log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart}"
......
......@@ -147,6 +147,7 @@ ARGS_ONE_INSTANCE = [ArgInstance(min=1, max=1)]
ARGS_ONE_NODE = [ArgNode(min=1, max=1)]
def _ExtractTagsObject(opts, args):
"""Extract the tag type object.
......
......@@ -2909,12 +2909,16 @@ class LUSetNodeParams(LogicalUnit):
"""
node = self.node = self.cfg.GetNodeInfo(self.op.node_name)
if (self.op.master_candidate is not None or
self.op.drained is not None or
self.op.offline is not None):
# we can't change the master's node flags
if self.op.node_name == self.cfg.GetMasterNode():
raise errors.OpPrereqError("The master role can be changed"
" only via masterfailover")
if ((self.op.master_candidate == False or self.op.offline == True or
self.op.drained == True) and node.master_candidate):
# we will demote the node from master_candidate
if self.op.node_name == self.cfg.GetMasterNode():
raise errors.OpPrereqError("The master node has to be a"
" master candidate, online and not drained")
cp_size = self.cfg.GetClusterInfo().candidate_pool_size
num_candidates, _ = self.cfg.GetMasterCandidateStats()
if num_candidates <= cp_size:
......
......@@ -131,7 +131,7 @@ class Mainloop(object):
"""
for owner in self._signal_wait:
owner.OnSignal(signal.SIGCHLD)
owner.OnSignal(signum)
def RegisterSignal(self, owner):
"""Registers a receiver for signal notifications
......
......@@ -46,6 +46,8 @@ N_FIELDS = ["name", "offline", "master_candidate", "drained",
"mtotal", "mnode", "mfree",
"pinst_cnt", "sinst_cnt", "tags",
"ctotal", "cnodes", "csockets",
"pip", "sip", "serial_no", "role",
"pinst_list", "sinst_list",
]
_NR_DRAINED = "drained"
......@@ -513,8 +515,7 @@ class R_2_instances_name_reboot(baserlib.R_Generic):
instance_name = self.items[0]
reboot_type = self.queryargs.get('type',
[constants.INSTANCE_REBOOT_HARD])[0]
ignore_secondaries = bool(self.queryargs.get('ignore_secondaries',
[False])[0])
ignore_secondaries = bool(self._checkIntVariable('ignore_secondaries'))
op = opcodes.OpRebootInstance(instance_name=instance_name,
reboot_type=reboot_type,
ignore_secondaries=ignore_secondaries,
......@@ -537,7 +538,7 @@ class R_2_instances_name_startup(baserlib.R_Generic):
"""
instance_name = self.items[0]
force_startup = bool(self.queryargs.get('force', [False])[0])
force_startup = bool(self._checkIntVariable('force'))
op = opcodes.OpStartupInstance(instance_name=instance_name,
force=force_startup,
dry_run=bool(self.dryRun()))
......
......@@ -223,7 +223,7 @@ def EvacuateNode(opts, args):
cnt = [dst_node, iallocator].count(None)
if cnt != 1:
raise errors.OpPrereqError("One and only one of the -n and -i"
raise errors.OpPrereqError("One and only one of the -n and -I"
" options must be passed")
selected_fields = ["name", "sinst_list"]
......
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