Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 58c0441ccecf4694cc45a82f43fcf372a9090528
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Wed Dec 5 15:14:14 2012 -0500
still need something like a useful output when it does break
>---------------------------------------------------------------
copr-be.py | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/copr-be.py b/copr-be.py
index 3be1828..d98feea 100644
--- a/copr-be.py
+++ b/copr-be.py
@@ -28,7 +28,7 @@ class CoprBackend(object):
raise errors.CoprBackendError, "Must specify config_file"
self.config_file = config_file
- self._ext_opts = ext_opts # to stow our cli options for read_conf()
+ self.ext_opts = ext_opts # to stow our cli options for read_conf()
self.opts = self.read_conf()
logdir = os.path.dirname(self.opts.logfile)
@@ -79,8 +79,8 @@ class CoprBackend(object):
if not opts.jobsdir or not opts.destdir:
raise errors.CoprBackendError, "Incomplete Config - must specify jobsdir and destdir in configuration"
- if self._ext_opts:
- for v in self._ext_opts:
+ if self.ext_opts:
+ for v in self.ext_opts:
setattr(opts, v, self.ext_opts.get(v))
return opts
@@ -213,8 +213,9 @@ def main(args):
if 'cbe' in locals():
for w in cbe.workers:
w.terminate()
-
-
+ raise
+ except KeyboardInterrupt, e:
+ pass
if __name__ == '__main__':
try:
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 15066b2d6c9c9a00994d2b7be1f13612466367a7
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Wed Dec 5 15:08:52 2012 -0500
- make opts behave in face of cli-opts and on config reread
- make exit be a bit quieter on ctrl-c (I hope)
- prepare for a case where our builders are not dynamically created
- obey pyflakes and pychecker suggestions
>---------------------------------------------------------------
backend/dispatcher.py | 19 +++++++++++--------
copr-be.py | 20 +++++++++++++-------
2 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index 434e671..f96bdb1 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -95,6 +95,7 @@ class Worker(multiprocessing.Process):
self.opts = opts
self.kill_received = False
self.callback = callback
+ self.create = create
if not self.callback:
self.logfile = self.opts.worker_logdir + '/worker-%s.log' % self.worker_num
self.callback = WorkerCallback(logfile = self.logfile)
@@ -193,14 +194,15 @@ class Worker(multiprocessing.Process):
job.jobfile = jobfile
# spin up our build instance
- try:
- ip = self.spawn_instance()
- if not ip:
- raise errors.CoprWorkerError, "No IP found from creating instance"
+ if self.create:
+ try:
+ ip = self.spawn_instance()
+ if not ip:
+ raise errors.CoprWorkerError, "No IP found from creating instance"
- except ansible.errors.AnsibleError, e:
- self.callback.log('failure to setup instance: %s' % e)
- raise
+ except ansible.errors.AnsibleError, e:
+ self.callback.log('failure to setup instance: %s' % e)
+ raise
status = 1
job.started_on = time.time()
@@ -243,5 +245,6 @@ class Worker(multiprocessing.Process):
self.return_results(job)
self.callback.log('worker finished build: %s' % ip)
# clean up the instance
- self.terminate_instance(ip)
+ if self.create:
+ self.terminate_instance(ip)
diff --git a/copr-be.py b/copr-be.py
index a3e372a..3be1828 100644
--- a/copr-be.py
+++ b/copr-be.py
@@ -20,7 +20,7 @@ def _get_conf(cp, section, option, default):
class CoprBackend(object):
- def __init__(self, config_file=None):
+ def __init__(self, config_file=None, ext_opts=None):
# read in config file
# put all the config items into a single self.opts bunch
@@ -28,6 +28,7 @@ class CoprBackend(object):
raise errors.CoprBackendError, "Must specify config_file"
self.config_file = config_file
+ self._ext_opts = ext_opts # to stow our cli options for read_conf()
self.opts = self.read_conf()
logdir = os.path.dirname(self.opts.logfile)
@@ -78,6 +79,9 @@ class CoprBackend(object):
if not opts.jobsdir or not opts.destdir:
raise errors.CoprBackendError, "Incomplete Config - must specify jobsdir and destdir in configuration"
+ if self._ext_opts:
+ for v in self._ext_opts:
+ setattr(opts, v, self.ext_opts.get(v))
return opts
@@ -188,17 +192,19 @@ def parse_args(args):
print "No config file found at: %s" % opts.config_file
sys.exit(1)
- return opts,args
+ ret_opts = Bunch()
+ for o in ('daemonize', 'exit_on_worker', 'pidfile', 'config_file'):
+ setattr(ret_opts, o, getattr(opts, o))
+
+ return ret_opts
def main(args):
- opts,args = parse_args(args)
+ opts = parse_args(args)
try:
- cbe = CoprBackend(opts.config_file)
- cbe.opts.daemonize = opts.daemonize # just so we have it on hand
- cbe.opts.exit_on_worker = opts.exit_on_worker
+ cbe = CoprBackend(opts.config_file, ext_opts=opts)
if opts.daemonize:
daemonize(opts.pidfile)
cbe.run()
@@ -207,7 +213,7 @@ def main(args):
if 'cbe' in locals():
for w in cbe.workers:
w.terminate()
- raise
+
if __name__ == '__main__':
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 8fc0c3e6a2eb3cd253ccdc75f4c2c05743e3590d
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Wed Dec 5 01:37:24 2012 -0500
touch up the log outputs to make it easier to know what to do
>---------------------------------------------------------------
backend/dispatcher.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index eff1f27..e1a47dc 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -102,7 +102,7 @@ class Worker(multiprocessing.Process):
if ip:
self.callback.log('creating worker: %s' % ip)
else:
- self.callback.log('creating worker: with dynamic ip')
+ self.callback.log('creating worker: dynamic ip')
def spawn_instance(self):
"""call the spawn playbook to startup/provision a building instance"""
@@ -130,7 +130,9 @@ class Worker(multiprocessing.Process):
# if we get here we're in trouble
self.callback.log('No IP back from spawn_instance - dumping cache output')
self.callback.log(str(play.SETUP_CACHE))
- self.callback.log(play.stats.summarize('localhost'))
+ self.callback.log(str(play.stats.summarize('localhost')))
+ self.callback.log('Test spawn_instance playbook manually')
+
return None
def terminate_instance(self,ip):
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit c881da21fc3f7fa723610919f627411b25e1a8e2
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Wed Dec 5 00:59:54 2012 -0500
localhost as string to get back debug on heisenbug
>---------------------------------------------------------------
backend/dispatcher.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index 796a9b6..eff1f27 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -130,7 +130,7 @@ class Worker(multiprocessing.Process):
# if we get here we're in trouble
self.callback.log('No IP back from spawn_instance - dumping cache output')
self.callback.log(str(play.SETUP_CACHE))
- self.callback.log(play.stats.summarize(localhost))
+ self.callback.log(play.stats.summarize('localhost'))
return None
def terminate_instance(self,ip):
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 31ab388e827dbe9a279a8bb8eac76ff1acb60212
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Tue Dec 4 16:37:43 2012 -0500
more logging in error conditions having to do with spawning instances
>---------------------------------------------------------------
backend/dispatcher.py | 9 ++++++++-
copr-be.py | 1 +
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index 225b75d..bf80e28 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -99,7 +99,10 @@ class Worker(multiprocessing.Process):
self.logfile = self.opts.worker_logdir + '/worker-%s.log' % self.worker_num
self.callback = WorkerCallback(logfile = self.logfile)
- self.callback.log('creating worker: %s' % ip)
+ if ip:
+ self.callback.log('creating worker: %s' % ip)
+ else:
+ self.callback.log('creating worker: with dynamic ip')
def spawn_instance(self):
"""call the spawn playbook to startup/provision a building instance"""
@@ -123,6 +126,10 @@ class Worker(multiprocessing.Process):
if i =='localhost':
continue
return i
+
+ # if we get here we're in trouble
+ self.callback.log('No IP back from spawn_instance - dumping cache output')
+ self.callback.log(str(play.SETUP_CACHE))
return None
def terminate_instance(self,ip):
diff --git a/copr-be.py b/copr-be.py
index 2cc0fba..73ab70a 100644
--- a/copr-be.py
+++ b/copr-be.py
@@ -117,6 +117,7 @@ class CoprBackend(object):
# #insert a poison pill? Kill after something? I dunno.
# FIXME - if a worker bombs out - we need to check them
# and startup a new one if it happens
+ # check for dead workers and abort
for w in self.workers:
if not w.is_alive():
raise errors.CoprBackendError, "Worker died unexpectedly"
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 6159878f050c4739d84f32a8558ab36c1230298f
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Tue Dec 4 16:23:10 2012 -0500
if any worker dies and we don't know why - raise an exception to kill us off b/c
until we know all of the reasons why I'd rather just stop.
>---------------------------------------------------------------
copr-be.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/copr-be.py b/copr-be.py
index 0d20e20..2cc0fba 100644
--- a/copr-be.py
+++ b/copr-be.py
@@ -117,6 +117,9 @@ class CoprBackend(object):
# #insert a poison pill? Kill after something? I dunno.
# FIXME - if a worker bombs out - we need to check them
# and startup a new one if it happens
+ for w in self.workers:
+ if not w.is_alive():
+ raise errors.CoprBackendError, "Worker died unexpectedly"
time.sleep(self.opts.sleeptime)
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 0f2031cdcce6c5ddccdf7d2b427453db35f7dc77
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Tue Dec 4 16:01:00 2012 -0500
- output what mockremote is seeing to the chroot log for the pkg
- move around where we need to add check against pkgs
>---------------------------------------------------------------
backend/dispatcher.py | 18 ++++++++++++++----
backend/mockremote.py | 4 ----
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index 286cffd..411f95c 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -196,22 +196,32 @@ class Worker(multiprocessing.Process):
job.started_on = time.time()
for chroot in job.chroots:
+ chroot_destdir = job.destdir + '/' + chroot
# setup our target dir locally
- if not os.path.exists(job.destdir):
+ if not os.path.exists(chroot_destdir):
try:
- os.makedirs(job.destdir, mode=0755)
+ os.makedirs(chroot_destdir, mode=0755)
except (OSError, IOError), e:
- msg = "Could not make results dir for job: %s - %s" % (job.destdir, str(e))
+ msg = "Could not make results dir for job: %s - %s" % (chroot_destdir, str(e))
self.callback.log(msg)
status = 0
continue
+ # FIXME
+ # need a plugin hook or some mechanism to check random
+ # info about the pkgs
+ # this should use ansible to download the pkg on the remote system
+ # and run a series of checks on the package before we
+ # start the build - most importantly license checks.
+
+
self.callback.log('mockremote %s %s %s %s %s' % (ip, job.timeout, job.destdir, chroot, str(job.repos)))
try:
+ chrootlogfile = chroot_destdir + '/' + mockremote.log
mr = mockremote.MockRemote(builder=ip, timeout=job.timeout,
destdir=job.destdir, chroot=chroot, cont=True, recurse=True,
repos=job.repos,
- callback=mockremote.DefaultCallBack(quiet=True,logfn=self.logfile))
+ callback=mockremote.CLiLogCallBack(quiet=True,logfn=chrootlogfile))
mr.build_pkgs(job.pkgs)
except mockremote.MockRemoteError, e:
# record and break
diff --git a/backend/mockremote.py b/backend/mockremote.py
index a2a5f13..7698de9 100755
--- a/backend/mockremote.py
+++ b/backend/mockremote.py
@@ -492,10 +492,6 @@ class MockRemote(object):
r_log.write(b_err)
r_log.close()
- # FIXME
- # need a plugin hook or some mechanism to check random
- # info about the pkgs
-
# checking where to stick stuff
if not b_status:
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit d29ca180260fc7734eec05f31d0fe7ffbd855898
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Sat Dec 1 00:24:46 2012 -0500
need a bit more logging detail to see what's breaking and why
>---------------------------------------------------------------
backend/mockremote.py | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/backend/mockremote.py b/backend/mockremote.py
index 5bfb1f2..d7d0eed 100755
--- a/backend/mockremote.py
+++ b/backend/mockremote.py
@@ -481,6 +481,14 @@ class MockRemote(object):
self.callback.error(msg)
self.callback.end_download(pkg)
+ # write out whatever came from the builder call into the destdir/chroot
+ r_log = open(self.destdir + '/' + self.chroot + '/mockchain.log', 'a')
+ r_log.write('%s\n' % pkg)
+ r_log.write('stdout\n')
+ r_log.write(b_out)
+ r.log.write('stderr\n')
+ r.log.write(b_err)
+ r.log.close()
# FIXME
# need a plugin hook or some mechanism to check random