r5386 - in trunk/cumin: model/plumage python/cumin/grid
by croberts@fedoraproject.org
Author: croberts
Date: 2012-05-21 18:43:55 +0000 (Mon, 21 May 2012)
New Revision: 5386
Modified:
trunk/cumin/model/plumage/rosemary.xml
trunk/cumin/python/cumin/grid/dashboard.py
Log:
Adding new history tab on grid::overview to house the pool efficiency historical chart.
Modified: trunk/cumin/model/plumage/rosemary.xml
===================================================================
--- trunk/cumin/model/plumage/rosemary.xml 2012-05-21 14:22:22 UTC (rev 5385)
+++ trunk/cumin/model/plumage/rosemary.xml 2012-05-21 18:43:55 UTC (rev 5386)
@@ -30,7 +30,7 @@
</statistic>
<statistic name="efficiency">
- <title>Efficiency</title>
+ <title>Efficiency percentage</title>
</statistic>
</class>
Modified: trunk/cumin/python/cumin/grid/dashboard.py
===================================================================
--- trunk/cumin/python/cumin/grid/dashboard.py 2012-05-21 14:22:22 UTC (rev 5385)
+++ trunk/cumin/python/cumin/grid/dashboard.py 2012-05-21 18:43:55 UTC (rev 5386)
@@ -34,10 +34,30 @@
capacity = DashboardCapacity(app, "c")
self.add_tab(capacity)
+
+ history = DashboardHistory(app, "h")
+ self.add_tab(history)
def render_title(self, session):
return "Overview"
+class DashboardHistory(Widget):
+ def __init__(self, app, name):
+ super(DashboardHistory, self).__init__(app, name)
+
+ chart = self.PoolEfficiencyChart(app, "eff", app.model.com_redhat_grid_plumage.OSUtil)
+ chart.stats = ["efficiency"]
+ chart.max_samples = 250
+ chart.duration.param.default = "3600"
+ self.add_child(chart)
+
+ def render_title(self, session):
+ return "History"
+
+ class PoolEfficiencyChart(ReportingChart):
+ def render_title(self, session):
+ return "Pool efficiency"
+
class DashboardSummary(Widget):
def __init__(self, app, name, collector):
super(DashboardSummary, self).__init__(app, name)
11 years, 11 months
r5385 - trunk/cumin/python/cumin/usergrid
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-05-21 14:22:22 +0000 (Mon, 21 May 2012)
New Revision: 5385
Modified:
trunk/cumin/python/cumin/usergrid/model.strings
Log:
Change the query for user grid overview stats to sum running, idle and held across submission records for an owner rather than using the submitter records.
BZ812407
Modified: trunk/cumin/python/cumin/usergrid/model.strings
===================================================================
--- trunk/cumin/python/cumin/usergrid/model.strings 2012-05-18 20:22:17 UTC (rev 5384)
+++ trunk/cumin/python/cumin/usergrid/model.strings 2012-05-21 14:22:22 UTC (rev 5385)
@@ -1,7 +1,7 @@
[LoadUserJobStats.sql]
select
- sum(s."RunningJobs") as RunningJobs,
- sum(s."IdleJobs") as IdleJobs,
- sum(s."HeldJobs") as held
-from "com.redhat.grid"."Submitter" as s
+ sum(s."Running") as RunningJobs,
+ sum(s."Idle") as IdleJobs,
+ sum(s."Held") as held
+from "com.redhat.grid"."Submission" as s
where s."Owner" = '{user_name}'
11 years, 11 months
r5384 - trunk/wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-05-18 20:22:17 +0000 (Fri, 18 May 2012)
New Revision: 5384
Modified:
trunk/wooly/python/wooly/util.py
Log:
Modify the xml_escape routine to escape double quotes as " by default.
If a specific entity list is passed in, double quotes will not be escpaed unless
they are specified in the entity list.
BZ807970
Modified: trunk/wooly/python/wooly/util.py
===================================================================
--- trunk/wooly/python/wooly/util.py 2012-05-18 14:41:34 UTC (rev 5383)
+++ trunk/wooly/python/wooly/util.py 2012-05-18 20:22:17 UTC (rev 5384)
@@ -18,8 +18,12 @@
from parsley.collectionsex import *
+quote_entities = {'"': """}
+
def xml_escape(string, entities=None):
if type(string) in (str, unicode):
+ if entities is None:
+ entities = quote_entities
return escape(string, entities)
return string
11 years, 11 months
r5383 - in trunk/cumin: bin etc
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-05-18 14:41:34 +0000 (Fri, 18 May 2012)
New Revision: 5383
Modified:
trunk/cumin/bin/cumin-checkpid
trunk/cumin/etc/sysvinit-cumin
Log:
Tweaks to cumin-checkpid and calls from sysvinit
Modified: trunk/cumin/bin/cumin-checkpid
===================================================================
--- trunk/cumin/bin/cumin-checkpid 2012-05-17 19:55:39 UTC (rev 5382)
+++ trunk/cumin/bin/cumin-checkpid 2012-05-18 14:41:34 UTC (rev 5383)
@@ -41,8 +41,15 @@
parser = OptionParser()
parser.add_option("--exit", dest="exit", action="store_true", default=False,
- help="Wait for master init to indicate exit")
+ help="Wait for master init to indicate exit")
+ parser.add_option("--timeout", dest="timeout", default="5", type=int,
+ help="Seconds to wait (default 5) before returning -1" \
+ " when a pid or status file is missing. If both" \
+ " have been read but there is still no status" \
+ " value after timeout seconds, assume success" \
+ "(but a slow master)")
+
(options, args) = parser.parse_args()
# Wait for the pidfile to exist.
@@ -50,31 +57,33 @@
then = datetime.now()
while not os.path.isfile("/var/run/cumin.pid"):
sleep(0.25)
- if datetime.now() - then > timedelta(seconds=5):
+ if datetime.now() - then > timedelta(seconds=options.timeout):
return -1
- # Wait for a value
- if not read_val("/var/run/cumin.pid", then, 5):
+ # Wait for a value. This also should happen very
+ # quickly, since the cumin master script write the
+ # pid very early.
+ if not read_val("/var/run/cumin.pid", then, options.timeout):
return -1
- # Now wait for the status file.
+ # Now wait for the status file. It should have
+ # been created before the pid value was written.
# Get the path from a config object for the master.
config = CuminMasterConfig()
p = config.get_init_status_path()
while not os.path.isfile(p):
sleep(0.25)
- if datetime.now() - then > timedelta(seconds=5):
+ if datetime.now() - then > timedelta(seconds=options.timeout):
return -1
# We don't care about the status value here, we
- # just want to see "exit" on the last line of the
- # file
+ # just want to see "exit" on the last line.
if options.exit:
- return read_exit(p, then, 5)
+ return read_exit(p, then, options.timeout)
# Let's read the status. If there is no
# value there, assume success.
- status = read_val(p, then, 10)
+ status = read_val(p, then, options.timeout)
if status is None:
status = 0
return status
Modified: trunk/cumin/etc/sysvinit-cumin
===================================================================
--- trunk/cumin/etc/sysvinit-cumin 2012-05-17 19:55:39 UTC (rev 5382)
+++ trunk/cumin/etc/sysvinit-cumin 2012-05-18 14:41:34 UTC (rev 5383)
@@ -88,7 +88,7 @@
RETVAL=$?
[ $RETVAL = 0 ] && touch $lockfile
if [ $RETVAL = 0 ]; then
- /usr/sbin/cumin-checkpid
+ /usr/sbin/cumin-checkpid --timeout=$DELAY
RETVAL=$?
fi
@@ -96,7 +96,7 @@
if [ $RETVAL -ne 0 ] ; then
# We want to remove the pidfile when the
# cumin master indicates exit
- /usr/sbin/cumin-checkpid --exit
+ /usr/sbin/cumin-checkpid --exit --timeout=$DELAY
if [ $? = 0 ]; then
rm -f $lockfile
rm -f $pidfile
@@ -114,12 +114,12 @@
status $processname -p $pidfile -l $lockfile &> /dev/null
running=$?
- killproc -d $(($DELAY-1)) $servicename SIGTERM
+ killproc $servicename SIGTERM
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
if [ $running -eq 0 ]; then
- /usr/sbin/cumin-checkpid --exit
+ /usr/sbin/cumin-checkpid --exit --timeout=$DELAY
if [ $? -eq 0 ]; then
rm -f $lockfile
rm -f $pidfile
11 years, 11 months
r5382 - in trunk/cumin: bin etc
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-05-17 19:55:39 +0000 (Thu, 17 May 2012)
New Revision: 5382
Modified:
trunk/cumin/bin/cumin
trunk/cumin/bin/cumin-checkpid
trunk/cumin/etc/sysvinit-cumin
Log:
More tweaks to sync between initd and cumin and management of pid files
BZ801287
Modified: trunk/cumin/bin/cumin
===================================================================
--- trunk/cumin/bin/cumin 2012-05-17 15:35:36 UTC (rev 5381)
+++ trunk/cumin/bin/cumin 2012-05-17 19:55:39 UTC (rev 5382)
@@ -55,9 +55,13 @@
syslog.syslog("cumin: master script exited with errors, see %s/log/master.log" % home)
# Used to write the pidfile and the startup status files.
-def write_status_path(p, value):
+def write_status_path(p, value, append=False):
+ if append:
+ mode = "a+"
+ else:
+ mode = "w+"
try:
- f = open(p, "w+")
+ f = open(p, mode)
if value:
f.write(value)
f.close()
@@ -180,13 +184,13 @@
if not options:
v = log_parse_errors(r)
write_status_path(config.get_init_status_path(),
- str(v)+"\n")
+ str(v)+"\nexit\n")
return v
if len(args) != 0:
log.error("Extra arguments:" + "".join([" "+arg for arg in args]))
_syslog.log()
- write_status_path(config.get_init_status_path(), "1\n")
+ write_status_path(config.get_init_status_path(), "1\nexit\n")
return 1
apps = []
@@ -219,7 +223,7 @@
init_files.append(init_path)
apps.append([None, args, prog_string, init_path])
- # Clear the init file
+ # Clear the init file for the app
write_status_path(init_path, "")
# Launch and babysit, do not restart if options.init_only is set
@@ -296,14 +300,14 @@
init_files.remove(app[INIT_FILE])
if len(init_files) == 0:
write_status_path(config.get_init_status_path(),
- "0"+"\n")
+ "0\n")
wrote_status = True
finally:
# Hmm, exiting, but we haven't written the status file yet.
# If we had seen an init failure from a child we would have
# written the file. Let's assume it was a success.
if not wrote_status:
- write_status_path(config.get_init_status_path(), "0"+"\n")
+ write_status_path(config.get_init_status_path(), "0\n")
log.info("Write termination string to all children")
complete = 0
for app in apps:
@@ -342,7 +346,8 @@
log.warn("Subprocess (%s) failed to stop"\
% app[PROCESS].pid)
break
-
+
+ write_status_path(config.get_init_status_path(), "exit\n", append=True)
return return_code
if __name__ == "__main__":
Modified: trunk/cumin/bin/cumin-checkpid
===================================================================
--- trunk/cumin/bin/cumin-checkpid 2012-05-17 15:35:36 UTC (rev 5381)
+++ trunk/cumin/bin/cumin-checkpid 2012-05-17 19:55:39 UTC (rev 5382)
@@ -3,27 +3,48 @@
import os
from datetime import datetime, timedelta
from time import sleep
+from optparse import OptionParser
home = os.environ.get("CUMIN_HOME", os.path.normpath("/usr/share/cumin"))
sys.path.append(os.path.join(home, "python"))
from cumin.config import CuminMasterConfig
+def read_exit(p, then, timeout):
+ while True:
+ try:
+ f = open(p, "r")
+ # Get the last line of the file
+ v = f.readlines()[-1:]
+ if len(v) and v[0][:-1] == "exit":
+ return 0
+ if datetime.now() - then > timedelta(seconds=timeout):
+ return -1
+ sleep(0.25)
+ except:
+ return -1
+
def read_val(p, then, timeout):
- while True:
+ while True:
try:
f = open(p, "r")
v = f.readline()
if v:
- return int(v[:-1])
+ return int(v[:-1])
if datetime.now() - then > timedelta(seconds=timeout):
- return None
+ return None
sleep(0.25)
except:
return None
def main():
+ parser = OptionParser()
+ parser.add_option("--exit", dest="exit", action="store_true", default=False,
+ help="Wait for master init to indicate exit")
+
+ (options, args) = parser.parse_args()
+
# Wait for the pidfile to exist.
# When called from service this should be immediate
then = datetime.now()
@@ -31,9 +52,8 @@
sleep(0.25)
if datetime.now() - then > timedelta(seconds=5):
return -1
-
- # We need a value written to the pid file otherwise
- # assume the service failed
+
+ # Wait for a value
if not read_val("/var/run/cumin.pid", then, 5):
return -1
@@ -46,7 +66,13 @@
if datetime.now() - then > timedelta(seconds=5):
return -1
- # Okay, now let's read the status. If there is no
+ # We don't care about the status value here, we
+ # just want to see "exit" on the last line of the
+ # file
+ if options.exit:
+ return read_exit(p, then, 5)
+
+ # Let's read the status. If there is no
# value there, assume success.
status = read_val(p, then, 10)
if status is None:
Modified: trunk/cumin/etc/sysvinit-cumin
===================================================================
--- trunk/cumin/etc/sysvinit-cumin 2012-05-17 15:35:36 UTC (rev 5381)
+++ trunk/cumin/etc/sysvinit-cumin 2012-05-17 19:55:39 UTC (rev 5382)
@@ -94,6 +94,13 @@
# Tidy up the banner
if [ $RETVAL -ne 0 ] ; then
+ # We want to remove the pidfile when the
+ # cumin master indicates exit
+ /usr/sbin/cumin-checkpid --exit
+ if [ $? = 0 ]; then
+ rm -f $lockfile
+ rm -f $pidfile
+ fi
echo_failure; echo; return $RETVAL
fi
echo_success && echo
@@ -103,12 +110,23 @@
stop() {
echo -n $"Stopping cumin: "
- killproc -d $(($DELAY-1)) $servicename
+ # if we think it's running we'll wait before clearing the pidfile
+ status $processname -p $pidfile -l $lockfile &> /dev/null
+ running=$?
+
+ killproc -d $(($DELAY-1)) $servicename SIGTERM
RETVAL=$?
- echo
+ echo
if [ $RETVAL -eq 0 ]; then
- rm -f /var/lock/subsys/$servicename
- rm -f /var/run/cumin.pid
+ if [ $running -eq 0 ]; then
+ /usr/sbin/cumin-checkpid --exit
+ if [ $? -eq 0 ]; then
+ rm -f $lockfile
+ rm -f $pidfile
+ else
+ echo "Timed out, cumin may not have stopped completely."
+ fi
+ fi
else
if [[ "$EUID" != "0" ]]; then
echo "Must be run as root"
11 years, 11 months
r5381 - in trunk/cumin: bin etc
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-05-17 15:35:36 +0000 (Thu, 17 May 2012)
New Revision: 5381
Modified:
trunk/cumin/bin/cumin-checkpid
trunk/cumin/etc/sysvinit-cumin
Log:
Manage pidfile from /etc/init.d/cumin. Communicate startup status of the service to initd with a call to cumin-checkpid. Eliminate the double-start for init checks.
BZ801287
Modified: trunk/cumin/bin/cumin-checkpid
===================================================================
--- trunk/cumin/bin/cumin-checkpid 2012-05-16 19:55:30 UTC (rev 5380)
+++ trunk/cumin/bin/cumin-checkpid 2012-05-17 15:35:36 UTC (rev 5381)
@@ -3,45 +3,56 @@
import os
from datetime import datetime, timedelta
from time import sleep
+
+home = os.environ.get("CUMIN_HOME", os.path.normpath("/usr/share/cumin"))
+sys.path.append(os.path.join(home, "python"))
+
from cumin.config import CuminMasterConfig
+
+def read_val(p, then, timeout):
+ while True:
+ try:
+ f = open(p, "r")
+ v = f.readline()
+ if v:
+ return int(v[:-1])
+ if datetime.now() - then > timedelta(seconds=timeout):
+ return None
+ sleep(0.25)
+ except:
+ return None
+
def main():
- # Wait for the pidfile to exist
+ # Wait for the pidfile to exist.
+ # When called from service this should be immediate
then = datetime.now()
while not os.path.isfile("/var/run/cumin.pid"):
sleep(0.25)
- if datetime.now() - then > timedelta(seconds=10):
+ if datetime.now() - then > timedelta(seconds=5):
return -1
+
+ # We need a value written to the pid file otherwise
+ # assume the service failed
+ if not read_val("/var/run/cumin.pid", then, 5):
+ return -1
- # Okay, we have a pid. Now wait for the status file.
+ # Now wait for the status file.
# Get the path from a config object for the master.
config = CuminMasterConfig()
p = config.get_init_status_path()
while not os.path.isfile(p):
sleep(0.25)
- if datetime.now() - then > timedelta(seconds=10):
+ if datetime.now() - then > timedelta(seconds=5):
return -1
- # Okay, now let's read the status.
- # It should be an int on the first line.
- while True:
- try:
- f = open(p, "r")
- v = f.readline()
- if v:
- return int(v[:-1])
+ # Okay, now let's read the status. If there is no
+ # value there, assume success.
+ status = read_val(p, then, 10)
+ if status is None:
+ status = 0
+ return status
- # Okay, if the master has not written an init error
- # status within 10 seconds, assume everything is fine
- if datetime.now() - then > timedelta(seconds=10):
- return 0
-
- sleep(0.25)
- except:
- print "\ncumin-checkpid error, assuming service start"
- break
- return 0
-
if __name__ == "__main__":
try:
sys.exit(main())
Modified: trunk/cumin/etc/sysvinit-cumin
===================================================================
--- trunk/cumin/etc/sysvinit-cumin 2012-05-16 19:55:30 UTC (rev 5380)
+++ trunk/cumin/etc/sysvinit-cumin 2012-05-17 15:35:36 UTC (rev 5381)
@@ -16,6 +16,8 @@
# so we can rearrange this easily
processname=cumin
servicename=cumin
+pidfile=/var/run/cumin.pid
+lockfile=/var/lock/subsys/cumin
RETVAL=0
DELAY=5
@@ -73,22 +75,29 @@
}
# If it's already running, be happy and return success
- status $processname &> /dev/null
+ status $processname -p $pidfile -l $lockfile &> /dev/null
[ $? -eq 0 ] && echo_success && echo && return
- # Invoke in foreground with arguments to test validity.
- # Leave stderr alone, so that something like an import error or a missing
- # module will still be seen.
- daemon --user cumin --check $servicename $processname \
- "--init-only "$CUMIN_OPTIONS < /dev/null > /dev/null
- if [ $? -ne 0 ] ; then
- echo_failure; echo; return
+ # Make sure the pid file is there and empty so cumin can write it
+ cat /dev/null > $pidfile
+ chown cumin.cumin $pidfile
+
+ # Squelch all IO, let cumin redirect.
+ # Cumin will write the value in the pidfile.
+ daemon --pidfile $pidfile --user cumin --check $servicename $processname "--p --timeout="$DELAY $CUMIN_OPTIONS < /dev/null &> /dev/null \&
+ RETVAL=$?
+ [ $RETVAL = 0 ] && touch $lockfile
+ if [ $RETVAL = 0 ]; then
+ /usr/sbin/cumin-checkpid
+ RETVAL=$?
fi
- # Launch for real now...Since we already did an init check assume success
- # Squelch all IO, let cumin redirect.
- daemon --user cumin --check $servicename $processname "--timeout="$DELAY $CUMIN_OPTIONS < /dev/null &> /dev/null \&
- echo_success && touch /var/lock/subsys/$servicename && echo
+ # Tidy up the banner
+ if [ $RETVAL -ne 0 ] ; then
+ echo_failure; echo; return $RETVAL
+ fi
+ echo_success && echo
+ return $RETVAL
}
stop() {
11 years, 11 months
r5380 - in trunk/cumin: bin python/cumin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-05-16 19:55:30 +0000 (Wed, 16 May 2012)
New Revision: 5380
Added:
trunk/cumin/bin/cumin-checkpid
Modified:
trunk/cumin/bin/cumin
trunk/cumin/bin/cumin-data
trunk/cumin/bin/cumin-report
trunk/cumin/bin/cumin-web
trunk/cumin/python/cumin/config.py
Log:
Add pidfile writing in the cumin master. Add cumin-checkpid to check for the existence of the pidfile and return cumin startup status. This eliminates the need for the sysvinit script to do a double start (run with init checks first, followed by a full run). sysvinit will be updated separately.
BZ801287
Modified: trunk/cumin/bin/cumin
===================================================================
--- trunk/cumin/bin/cumin 2012-05-16 18:23:13 UTC (rev 5379)
+++ trunk/cumin/bin/cumin 2012-05-16 19:55:30 UTC (rev 5380)
@@ -54,15 +54,43 @@
home = os.environ.get("CUMIN_HOME", os.path.normpath("/usr/share/cumin"))
syslog.syslog("cumin: master script exited with errors, see %s/log/master.log" % home)
+# Used to write the pidfile and the startup status files.
+def write_status_path(p, value):
+ try:
+ f = open(p, "w+")
+ if value:
+ f.write(value)
+ f.close()
+ except:
+ pass
+
+def read_status_path(p):
+ try:
+ f = open(p, "r")
+ v = f.readline()
+ if v:
+ v = v[:-1]
+ except:
+ v = ""
+ return v
+
def main():
# tuple indices, for clarity
PROCESS = 0
ARGS = 1
PROG_STRING = 2
+ INIT_FILE = 3
+ wrote_status = False
+
config = CuminMasterConfig()
+ # Clear the status path file. A monitoring program will
+ # check for writes here to find out the status of init
+ # checks (after a pidfile is written)
+ write_status_path(config.get_init_status_path(), "")
+
# Trap exit from parser and save standard error for logging
# Then put stderr back to original value
r, w = os.pipe()
@@ -114,6 +142,9 @@
parser.add_option("--syslog", dest="syslog", action="store_true", default=False,
help="Log general error notfications to syslog. Intended for systemd")
+ parser.add_option("--p", dest="write_pid", action="store_true", default=False,
+ help="Write the pid file (/var/run/cumin.pid). For service starts.")
+
(options, args) = parser.parse_args()
except SystemExit:
options = args = None
@@ -123,56 +154,74 @@
sys.stderr.close()
sys.stderr = sys.__stderr__
- # Parse may have failed, in which case make a quick check for options ourselves
+ # Parse may have failed, in which case make a quick check for important
+ # options ourselves
if options:
_syslog.enabled = options.syslog
console = options.console
+ write_pid = options.write_pid
else:
_syslog.enabled = "--syslog" in sys.argv[1:]
console = "--console" in sys.argv[1:]
+ write_pid = "--p" in sys.argv[1:]
+
+ # Write the pidfile
+ if write_pid:
+ write_status_path("/var/run/cumin.pid", str(os.getpid())+"\n")
+
+ # Set up logging
if console:
log_dest = sys.stderr
else:
log_dest = os.path.join(home, "log", "master.log")
enable_logging("cumin.master", logging.INFO, log_dest)
-
# Parser exited, either on --help or with errors
if not options:
- return log_parse_errors(r)
-
+ v = log_parse_errors(r)
+ write_status_path(config.get_init_status_path(),
+ str(v)+"\n")
+ return v
+
if len(args) != 0:
log.error("Extra arguments:" + "".join([" "+arg for arg in args]))
_syslog.log()
+ write_status_path(config.get_init_status_path(), "1\n")
return 1
- # Get our list of cumin-web and data instances
- # create list elements to hold the process object, section arg, and app
apps = []
- if len(options.webs) > 0:
- for instance in options.webs.split(','):
- args, prog_string = get_args("cumin-web", instance,
- options.init_only, console,
- exit_s, options.timeout,
- options.web_options)
- apps.append([None, args, prog_string])
+ init_files = []
- if len(options.datas) > 0:
- for instance in options.datas.split(','):
- args, prog_string = get_args("cumin-data", instance,
- options.init_only, console,
- exit_s, options.timeout,
- options.data_options)
- apps.append([None, args, prog_string])
+ # This gives us the list of section names, plus the app name,
+ # plus extra options to pass on to the children for each app type
+ sections = [options.webs, options.datas, options.reports]
+ names = ["cumin-web", "cumin-data", "cumin-report"]
+ child_options = [options.web_options,
+ options.data_options,
+ options.report_options]
+ zipped = zip(sections, names, child_options)
- if len(options.reports) > 0:
- for instance in options.reports.split(','):
- args, prog_string = get_args("cumin-report", instance,
- options.init_only, console,
- exit_s, options.timeout,
- options.report_options)
- apps.append([None, args, prog_string])
-
+ for info in zipped:
+ instances, app, extra_options = info
+ if len(instances) > 0:
+ for instance in instances.split(','):
+ instance = instance.strip()
+
+ args, prog_string = get_args(app,
+ instance,
+ options.init_only,
+ console,
+ exit_s,
+ options.timeout,
+ extra_options)
+
+ init_path = config.get_init_status_path(instance)
+ init_files.append(init_path)
+ apps.append([None, args, prog_string, init_path])
+
+ # Clear the init file
+ write_status_path(init_path, "")
+
# Launch and babysit, do not restart if options.init_only is set
complete = 0
return_code = 0
@@ -218,6 +267,9 @@
app[PROCESS] = None
return_code = 2
complete = len(apps)
+ write_status_path(config.get_init_status_path(),
+ str(poll)+"\n")
+ wrote_status = True
break
else:
log.info("Subprocess (%s) exited with status %s (%s), %s"\
@@ -229,7 +281,29 @@
complete += 1
else:
start(app, "Restart")
+
+ elif app[INIT_FILE] in init_files:
+ # Check the init status file for the child so that we know
+ # it has made it through init checks. When all children
+ # have made it through init checks, we write our own status.
+ value = read_status_path(app[INIT_FILE])
+ if value:
+ if value != "0":
+ # we should see an init failure soon
+ # ignore init_files and wait for the poll
+ init_files = []
+ else:
+ init_files.remove(app[INIT_FILE])
+ if len(init_files) == 0:
+ write_status_path(config.get_init_status_path(),
+ "0"+"\n")
+ wrote_status = True
finally:
+ # Hmm, exiting, but we haven't written the status file yet.
+ # If we had seen an init failure from a child we would have
+ # written the file. Let's assume it was a success.
+ if not wrote_status:
+ write_status_path(config.get_init_status_path(), "0"+"\n")
log.info("Write termination string to all children")
complete = 0
for app in apps:
Added: trunk/cumin/bin/cumin-checkpid
===================================================================
--- trunk/cumin/bin/cumin-checkpid (rev 0)
+++ trunk/cumin/bin/cumin-checkpid 2012-05-16 19:55:30 UTC (rev 5380)
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+import sys
+import os
+from datetime import datetime, timedelta
+from time import sleep
+from cumin.config import CuminMasterConfig
+def main():
+
+ # Wait for the pidfile to exist
+ then = datetime.now()
+ while not os.path.isfile("/var/run/cumin.pid"):
+ sleep(0.25)
+ if datetime.now() - then > timedelta(seconds=10):
+ return -1
+
+ # Okay, we have a pid. Now wait for the status file.
+ # Get the path from a config object for the master.
+ config = CuminMasterConfig()
+ p = config.get_init_status_path()
+ while not os.path.isfile(p):
+ sleep(0.25)
+ if datetime.now() - then > timedelta(seconds=10):
+ return -1
+
+ # Okay, now let's read the status.
+ # It should be an int on the first line.
+ while True:
+ try:
+ f = open(p, "r")
+ v = f.readline()
+ if v:
+ return int(v[:-1])
+
+ # Okay, if the master has not written an init error
+ # status within 10 seconds, assume everything is fine
+ if datetime.now() - then > timedelta(seconds=10):
+ return 0
+
+ sleep(0.25)
+ except:
+ print "\ncumin-checkpid error, assuming service start"
+ break
+ return 0
+
+if __name__ == "__main__":
+ try:
+ sys.exit(main())
+ except KeyboardInterrupt:
+ sys.exit(0)
Property changes on: trunk/cumin/bin/cumin-checkpid
___________________________________________________________________
Added: svn:executable
+ *
Modified: trunk/cumin/bin/cumin-data
===================================================================
--- trunk/cumin/bin/cumin-data 2012-05-16 18:23:13 UTC (rev 5379)
+++ trunk/cumin/bin/cumin-data 2012-05-16 19:55:30 UTC (rev 5380)
@@ -95,9 +95,19 @@
ret = ret << 1 | passed_init
return ret
+def write_status_path(p, value):
+ try:
+ f = open(p, "w+")
+ if value:
+ f.write(value)
+ f.close()
+ except:
+ pass
+
def main():
passed_init = 1
return_code = CuminErrors.NO_ERROR
+ wrote_status = False
# Do our own simple option check so we can redirect IO early
# without worrying about other options or the behavior of optParse
@@ -135,6 +145,8 @@
try:
mint = None
+ config = None
+
setup_initial_logging()
parser = BrokeredOptionParser()
@@ -168,7 +180,6 @@
if len(args) != 0:
log.error("Extra arguments:" + "".join([" "+arg for arg in args]))
raise ArgError
-
model_dir = [os.path.join(config.home, x) for x in ("model", "model/admin")]
@@ -208,6 +219,10 @@
return_code, agents = process_agents(values.agents, opts.section)
mint.qmf_agents = agents
+ # Okay, record the init check status here
+ write_status_path(config.get_init_status_path(), str(return_code)+"\n")
+ wrote_status = True
+
# If init_only was set or we failed init, don't proceed...
if not opts.init_only and not return_code:
passed_init = 0
@@ -271,6 +286,12 @@
print_exc()
return_code = CuminErrors.UNHANDLED_ERROR
+ # For parse errors, for example, we won't have a config object yet
+ # but the return code will indicate an init error anyway so a
+ # parent can check the return code.
+ if not wrote_status and config:
+ write_status_path(config.get_init_status_path(), str(return_code)+"\n")
+
def shutdown():
if mint:
mint.stop()
Modified: trunk/cumin/bin/cumin-report
===================================================================
--- trunk/cumin/bin/cumin-report 2012-05-16 18:23:13 UTC (rev 5379)
+++ trunk/cumin/bin/cumin-report 2012-05-16 19:55:30 UTC (rev 5380)
@@ -65,9 +65,20 @@
ret = ret << 1 | passed_init
return ret
+def write_status_path(p, value):
+ try:
+ f = open(p, "w+")
+ if value:
+ f.write(value)
+ f.close()
+ except:
+ pass
+
def main():
passed_init = 1
return_code = CuminErrors.NO_ERROR
+ wrote_status = False
+ config = None
# Do our own simple option check so we can redirect IO early
# without worrying about other options or the behavior of optParse
@@ -185,6 +196,10 @@
if opts.init_only and opts.delete_on_start:
mint.update_thread._delete_all_objects()
+ # Okay, record the init check status here
+ write_status_path(config.get_init_status_path(), str(return_code)+"\n")
+ wrote_status = True
+
# If init_only was set or we failed init, don't proceed...
if not opts.init_only and not return_code:
passed_init = 0
@@ -248,6 +263,12 @@
print_exc()
return_code = CuminErrors.UNHANDLED_ERROR
+ # For parse errors, for example, we won't have a config object yet
+ # but the return code will indicate an init error anyway so a
+ # parent can check the return code.
+ if not wrote_status and config:
+ write_status_path(config.get_init_status_path(), str(return_code)+"\n")
+
def shutdown():
if mint:
mint.stop()
Modified: trunk/cumin/bin/cumin-web
===================================================================
--- trunk/cumin/bin/cumin-web 2012-05-16 18:23:13 UTC (rev 5379)
+++ trunk/cumin/bin/cumin-web 2012-05-16 19:55:30 UTC (rev 5380)
@@ -98,9 +98,19 @@
ret = ret << 1 | passed_init
return ret
+def write_status_path(p, value):
+ try:
+ f = open(p, "w+")
+ if value:
+ f.write(value)
+ f.close()
+ except:
+ pass
+
def main():
passed_init = 1
return_code = CuminErrors.NO_ERROR
+ wrote_status = False
# Do our own simple option check so we can redirect IO early
# without worrying about other options or the behavior of optParse
@@ -143,6 +153,7 @@
try:
cumin = None
+ config = None
setup_initial_logging()
@@ -227,6 +238,10 @@
cumin.check()
cumin.init()
+ # Okay, record the init check status here
+ write_status_path(config.get_init_status_path(), str(return_code)+"\n")
+ wrote_status = True
+
if not opts.init_only and not return_code:
passed_init = 0
@@ -280,6 +295,12 @@
traceback.print_exc()
return_code = CuminErrors.UNHANDLED_ERROR
+ # For parse errors, for example, we won't have a config object yet
+ # but the return code will indicate an init error anyway so a
+ # parent can check the return code.
+ if not wrote_status and config:
+ write_status_path(config.get_init_status_path(), str(return_code)+"\n")
+
def shutdown():
if cumin:
cumin.stop()
Modified: trunk/cumin/python/cumin/config.py
===================================================================
--- trunk/cumin/python/cumin/config.py 2012-05-16 18:23:13 UTC (rev 5379)
+++ trunk/cumin/python/cumin/config.py 2012-05-16 19:55:30 UTC (rev 5380)
@@ -8,7 +8,7 @@
log = logging.getLogger("cumin.config")
class CuminConfig(Config):
- def __init__(self):
+ def __init__(self, section_name):
super(CuminConfig, self).__init__()
hdef = os.path.normpath("/usr/share/cumin")
@@ -17,12 +17,22 @@
if not os.path.isdir(self.home):
raise Exception("Home path '%s' is not a directory")
+ # Remember the config section we were created with
+ self.section_name = section_name
+
def get_home(self):
return self.home
def get_access_root(self):
return os.path.join(self.home, "model/access/")
+ def get_init_status_path(self, section_name=""):
+ if not section_name:
+ section_name = self.section_name
+ if section_name:
+ return os.path.join(self.home, "log", "." + section_name + ".init")
+ return ""
+
def parse(self):
paths = list()
@@ -39,20 +49,20 @@
file for apps which do not need any more
'''
def __init__(self):
- super(CuminCommonConfig, self).__init__()
+ super(CuminCommonConfig, self).__init__("common")
- self.section = CuminConfigSection(self, "common")
+ self.section = CuminConfigSection(self, self.section_name)
def set_log(self, log):
self.section.log_file.default = log
class CuminWebConfig(CuminConfig):
def __init__(self, section_name="web", strict_section="False"):
- super(CuminWebConfig, self).__init__()
+ super(CuminWebConfig, self).__init__(section_name)
- web = CuminWebConfigSection(self, section_name, strict_section)
+ web = CuminWebConfigSection(self, self.section_name, strict_section)
web.log_file.default = os.path.join(self.home, "log",
- section_name + ".log")
+ self.section_name + ".log")
def _common_data_section(self, data, name):
data.log_file.default = os.path.join(self.home, "log", name + ".log")
@@ -77,23 +87,24 @@
class CuminDataConfig(CuminConfig):
def __init__(self, section_name="data", strict_section=False):
- super(CuminDataConfig, self).__init__()
+ super(CuminDataConfig, self).__init__(section_name)
- data = CuminDataConfigSection(self, section_name, strict_section)
- _common_data_section(self, data, section_name)
+ data = CuminDataConfigSection(self, self.section_name, strict_section)
+ _common_data_section(self, data, self.section_name)
class CuminReportConfig(CuminConfig):
def __init__(self, section_name="report", strict_section=False):
- super(CuminReportConfig, self).__init__()
+ super(CuminReportConfig, self).__init__(section_name)
- data = CuminReportConfigSection(self, section_name, strict_section)
- _common_data_section(self, data, section_name)
+ data = CuminReportConfigSection(self,
+ self.section_name, strict_section)
+ _common_data_section(self, data, self.section_name)
class CuminMasterConfig(CuminConfig):
def __init__(self, section_name="master", strict_section=False):
- super(CuminMasterConfig, self).__init__()
+ super(CuminMasterConfig, self).__init__(section_name)
- master = ConfigSection(self, section_name, strict_section)
+ master = ConfigSection(self, self.section_name, strict_section)
param = ConfigParameter(master, "datas", str)
param.default = "data"
11 years, 11 months
r5379 - trunk/cumin/python/cumin/grid
by croberts@fedoraproject.org
Author: croberts
Date: 2012-05-16 18:23:13 +0000 (Wed, 16 May 2012)
New Revision: 5379
Modified:
trunk/cumin/python/cumin/grid/negotiator.py
Log:
Addressing BZ 760567. As part of the change to non-flash-based charting, the mechanism to load the quota page changed. That seems to have fixed this BZ. This commit is to remove some code that is no longer called (the code that caused the exception in this BZ) and to add some log messages in the event that a similar condition affects the new code.
Modified: trunk/cumin/python/cumin/grid/negotiator.py
===================================================================
--- trunk/cumin/python/cumin/grid/negotiator.py 2012-05-15 20:01:00 UTC (rev 5378)
+++ trunk/cumin/python/cumin/grid/negotiator.py 2012-05-16 18:23:13 UTC (rev 5379)
@@ -281,7 +281,7 @@
try:
dynamic_groups = ["%s" % x for x in groups if info[x]["GROUP_QUOTA_DYNAMIC"] != ""]
except:
- pass
+ log.error("Error when loading dynamic group values for quota editing.")
for group in sorted(groups):
if(group in dynamic_groups):
values.append(self.render_quota_value(session, group))
@@ -300,7 +300,7 @@
try:
dynamic_groups = ["%s" % x for x in groups if info[x]["GROUP_QUOTA_DYNAMIC"] != ""]
except:
- pass
+ log.error("Error when loading dynamic group names for quota editing.")
for group in sorted(groups):
if(group in dynamic_groups):
values.append(group)
@@ -319,7 +319,7 @@
try:
dynamic_groups = ["%s" % x for x in groups if info[x]["GROUP_QUOTA_DYNAMIC"] != ""]
except:
- pass
+ log.error("Error when loading dynamic groups for quota editing.")
for group in sorted(groups):
if(group in dynamic_groups):
self.field_tmpl.render(writer, session, group)
@@ -416,27 +416,6 @@
def render_height(self, session):
return 210
- def get_href_params(self, session):
- params = super(PriorityPieChart, self).get_href_params(session)
- params.append("width=%i" % self.render_width(session))
- params.append("height=%i" % self.render_height(session))
-
- # send the group names and values to the chart page so we
- # don't have to get them again
- group_leader = self.group_leader.get(session)
- groups = self.group_helper.get_siblings(session, group_leader)
- info = self.group_helper.get_config_info(session)
- names = ["name=%s" % x for x in groups if info[x]["GROUP_QUOTA_DYNAMIC"] != ""]
- params.extend(names)
- params.append("name=Unclaimed")
-
- vals = ["value=%s" % info[x]["GROUP_QUOTA_DYNAMIC"] for x in groups if info[x]["GROUP_QUOTA_DYNAMIC"] != ""]
- params.extend(vals)
- unclaimed = self.group_helper.get_unclaimed_dyn_quota(session, groups)
- params.append("value=%s" % str(unclaimed))
-
- return params
-
class NegotiatorGroupTask(ObjectFrameTask):
def do_exit(self, session):
self.app.main_page.main.grid.view.show(session)
11 years, 11 months
r5378 - trunk/cumin/etc
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-05-15 20:01:00 +0000 (Tue, 15 May 2012)
New Revision: 5378
Modified:
trunk/cumin/etc/sysvinit-cumin
Log:
Set RETVAL=2 on unknown parameter
BZ801291
Modified: trunk/cumin/etc/sysvinit-cumin
===================================================================
--- trunk/cumin/etc/sysvinit-cumin 2012-05-15 19:42:02 UTC (rev 5377)
+++ trunk/cumin/etc/sysvinit-cumin 2012-05-15 20:01:00 UTC (rev 5378)
@@ -132,6 +132,7 @@
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
+ RETVAL=2
;;
esac
exit $RETVAL
11 years, 11 months
r5377 - in trunk: cumin/bin parsley/python/parsley
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-05-15 19:42:02 +0000 (Tue, 15 May 2012)
New Revision: 5377
Modified:
trunk/cumin/bin/cumin-data
trunk/cumin/bin/cumin-report
trunk/cumin/bin/cumin-web
trunk/parsley/python/parsley/loggingex.py
Log:
Tweaks after testing.
* Make the PipeThread class daemonized.
* Also, provide a stop() with an immediate return for PipeThread so it can be called reliably from the main thread. Move pipethread.stop() out of the shutdown routine (so stderr and stdout are the very last things to be stopped).
BZ800065
Modified: trunk/cumin/bin/cumin-data
===================================================================
--- trunk/cumin/bin/cumin-data 2012-05-15 18:29:45 UTC (rev 5376)
+++ trunk/cumin/bin/cumin-data 2012-05-15 19:42:02 UTC (rev 5377)
@@ -274,8 +274,6 @@
def shutdown():
if mint:
mint.stop()
- if pipeThread:
- pipeThread.stop()
log.info("about to call logging shutdown")
logging.shutdown()
@@ -290,6 +288,8 @@
except:
tm = 5
t.join(tm)
+ if pipeThread:
+ pipeThread.stop(immediate=True)
return adjust_return(passed_init, return_code)
def make_ctrl_c(sig, frame):
Modified: trunk/cumin/bin/cumin-report
===================================================================
--- trunk/cumin/bin/cumin-report 2012-05-15 18:29:45 UTC (rev 5376)
+++ trunk/cumin/bin/cumin-report 2012-05-15 19:42:02 UTC (rev 5377)
@@ -251,8 +251,6 @@
def shutdown():
if mint:
mint.stop()
- if pipeThread:
- pipeThread.stop()
log.info("about to call logging shutdown")
logging.shutdown()
@@ -267,7 +265,8 @@
except:
tm = 5
t.join(tm)
-
+ if pipeThread:
+ pipeThread.stop(immediate=True)
return adjust_return(passed_init, return_code)
def make_ctrl_c(sig, frame):
Modified: trunk/cumin/bin/cumin-web
===================================================================
--- trunk/cumin/bin/cumin-web 2012-05-15 18:29:45 UTC (rev 5376)
+++ trunk/cumin/bin/cumin-web 2012-05-15 19:42:02 UTC (rev 5377)
@@ -283,8 +283,6 @@
def shutdown():
if cumin:
cumin.stop()
- if pipeThread:
- pipeThread.stop()
log.info("about to call logging shutdown")
logging.shutdown()
@@ -299,6 +297,8 @@
except:
tm = 5
t.join(tm)
+ if pipeThread:
+ pipeThread.stop(immediate=True)
return adjust_return(passed_init, return_code)
def make_ctrl_c(sig, frame):
Modified: trunk/parsley/python/parsley/loggingex.py
===================================================================
--- trunk/parsley/python/parsley/loggingex.py 2012-05-15 18:29:45 UTC (rev 5376)
+++ trunk/parsley/python/parsley/loggingex.py 2012-05-15 19:42:02 UTC (rev 5377)
@@ -163,7 +163,8 @@
that the thread has exited unexpectedly, potentially allowing them to clean up
the IO being handled by this thread.
"""
- def __init__(self, descriptors, paths, call_on_fail=None, rollover_size = 1024*1024):
+ def __init__(self, descriptors, paths, call_on_fail=None,
+ rollover_size = 1024*1024):
assert len(descriptors) == len(paths)
assert type(descriptors) in (list,tuple)
@@ -175,7 +176,8 @@
super(PipeLogThread, self).__init__()
self.name = self.__class__.__name__
-
+ self.immediate = False
+ self.daemon = True
self.rollover_size = rollover_size
self.call_on_fail = call_on_fail
@@ -208,10 +210,15 @@
try:
while not stop:
r, w, e = select.select(self.descriptors+[self.stop_r], [], [])
+
+ # If we have been told to stop immediately, do so.
+ if self.stop_r in r:
+ if self.immediate:
+ break
+ stop = True
+
for desc in r:
- if desc == self.stop_r:
- stop = True
- else:
+ if desc != self.stop_r:
msg = os.read(desc,1024)
if msg != "":
if self.rollover_size != 0:
@@ -227,9 +234,13 @@
for key, value in self.files.items():
value[0].close()
- def stop(self):
+ def stop(self, immediate=False):
if self.isAlive():
+ self.immediate = immediate
os.write(self.stop_w,"\n")
+ if immediate:
+ return
+
# This gives the thread a chance to write out
# anything pending on an input pipe.
for i in range(5):
11 years, 11 months