From: Thierry Parmentelat Date: Fri, 22 Jan 2010 11:29:00 +0000 (+0000) Subject: various tricks and notes for smoother debugging X-Git-Tag: NodeManager-2.0-1~6 X-Git-Url: http://git.onelab.eu/?p=nodemanager.git;a=commitdiff_plain;h=12c74117e7e48984c7fa26617c321bd445a3c4fb various tricks and notes for smoother debugging --- diff --git a/Makefile b/Makefile index eeab636..1a55599 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ install: --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \ --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \ --install-scripts=$(DESTDIR)/$(bindir) + install -m 444 README $(DESTDIR)/$(datadir)/NodeManager clean: python setup.py clean @@ -37,3 +38,57 @@ tags: .PHONY: tags +########## sync +# for use with the test framework; push local stuff on a test node +# make sync NODE=vnode01.inria.fr +# specify TESTMASTER and BUILD if the key is not available yet + +LOCAL_RSYNC_EXCLUDES := --exclude '*.pyc' +RSYNC_EXCLUDES := --exclude .svn --exclude CVS --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES) +RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,) +RSYNC := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES) + +ifdef NODE +NODEURL:=root@$(NODE):/ +endif + +sync: $(NODE).key.rsa +ifeq (,$(NODEURL)) + @echo "sync: You must define NODE on the command line" + @echo " e.g. make sync NODE=vnode01.inria.fr" + @exit 1 +else + +$(RSYNC) ./ $(NODEURL)/usr/share/NodeManager/ + +$(RSYNC) ./initscripts/nm $(NODEURL)/etc/init.d/nm +endif + +### fetching the key + +TESTMASTER ?= testmaster.onelab.eu + +ifdef BUILD +KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key1.rsa +endif + +$(NODE).key.rsa: +ifeq (,$(KEYURL)) + @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line" + @echo " e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr" + @echo " note that for now all test builds use the same key, so any BUILD would do" + @exit 1 +else + scp $(KEYURL) $@ +endif + +### utility - find out the node name for a given BUILD + +ifdef BUILD +NODEIPCOMMAND:=ssh root@$(TESTMASTER) cat $(BUILD)/arg-ips-node +endif + +nodename: +ifeq (,$(NODEIPCOMMAND)) + @echo "nodename: You must define TESTMASTER and BUILD on the command line" +else + $(NODEIPCOMMAND) +endif diff --git a/NodeManager.spec b/NodeManager.spec index 978280d..0f96ecd 100644 --- a/NodeManager.spec +++ b/NodeManager.spec @@ -61,9 +61,11 @@ local operations on slices. %setup -q %build +# make manages the C and Python stuff %{__make} %{?_smp_mflags} %install +# make manages the C and Python stuff rm -rf $RPM_BUILD_ROOT %{__make} %{?_smp_mflags} install DESTDIR="$RPM_BUILD_ROOT" diff --git a/README b/README index d049d21..c6233eb 100644 --- a/README +++ b/README @@ -5,3 +5,32 @@ The PlanetLab NodeManager manages all aspects of PlanetLab node and slice manage Copyright 2008 Princeton University http://www.planet-lab.org + +======================================== +--- NOTES on debugging + + +(*) service nm restartdebug +this lets you restart the nodemanager in interactive mode, and with faster periods + + +(*) logs +logging is a bit confusing; the main recipient is + /var/log/nm +together with + /var/log/nm.daemon (which should be empty) + +but beware that part of the logs eventually end up in + /vservers//var/log/nm +as well as in here (although this should not be used anymore by now) + /vservers//var/log/boot.log + + +(*) connecting with PLC +also, note that each time GetSlivers gets sucessfully fetched, it is saved in + /var/log/getslivers.txt + +When the connection is broken, for obscure reasons, all modules are +invoked anyway, but with an empty dict as data, triggering various +exceptions that complain about missing keys. In general these are red +herrings. diff --git a/initscripts/nm b/initscripts/nm index 61b7254..375e157 100755 --- a/initscripts/nm +++ b/initscripts/nm @@ -20,6 +20,8 @@ nm=${NM-"python /usr/share/NodeManager/nm.py"} prog="Node Manager" options=${OPTIONS-"-d -s"} restartoptions=${RESTARTOPTIONS-"-d"} +# debug mode is interactive, and has faster period +debugoptions=${DEBUGOPTIONS-"-p 60 -r 31"} pidfile=${PIDFILE-/var/run/nm.pid} lockfile=${LOCKFILE-/var/lock/subsys/nm} RETVAL=0 @@ -48,34 +50,33 @@ stop() [ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile} } -restart() -{ - stop - do_start $restartoptions -} - - case "$1" in start) - start - ;; + start + ;; stop) - stop - ;; + stop + ;; status) - status $nm - RETVAL=$? - ;; + status $nm + RETVAL=$? + ;; restart|reload) - restart - ;; + stop + do_start $restartoptions + ;; + restartdebug) + stop + echo "Running interactively .." + $nm $debugoptions + ;; condrestart) - if [ -f ${pidfile} ] ; then - restart - fi + if [ -f ${pidfile} ] ; then + restart + fi ;; *) - echo $"Usage: $0 {start|stop|restart|condrestart|status}" + echo $"Usage: $0 {start|stop|restart|condrestart|status|restartdebug}" exit 1 esac diff --git a/nm.py b/nm.py index 0776826..72fbd80 100755 --- a/nm.py +++ b/nm.py @@ -35,13 +35,18 @@ known_modules=['net','conf_files', 'sm', 'bwmon'] plugin_path = "/usr/share/NodeManager/plugins" +default_period=600 +default_random=301 + parser = optparse.OptionParser() parser.add_option('-d', '--daemon', action='store_true', dest='daemon', default=False, help='run daemonized') parser.add_option('-s', '--startup', action='store_true', dest='startup', default=False, help='run all sliver startup scripts') parser.add_option('-f', '--config', action='store', dest='config', default='/etc/planetlab/plc_config', help='PLC configuration file') parser.add_option('-k', '--session', action='store', dest='session', default='/etc/planetlab/session', help='API session key (or file)') -parser.add_option('-p', '--period', action='store', dest='period', default=600, help='Polling interval (sec)') -parser.add_option('-r', '--random', action='store', dest='random', default=301, help='Range for additional random polling interval (sec)') +parser.add_option('-p', '--period', action='store', dest='period', default=default_period, + help='Polling interval (sec) - default %d'%default_period) +parser.add_option('-r', '--random', action='store', dest='random', default=default_random, + help='Range for additional random polling interval (sec) -- default %d'%default_random) parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False, help='more verbose log') parser.add_option('-P', '--path', action='store', dest='path', default=plugin_path, help='Path to plugins directory')