Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 7080aebc8fbb3200c405c722b9301d755a313263
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Fri Nov 30 11:43:30 2012 -0500
need to record the ip of each worker so we can kill it later
>---------------------------------------------------------------
backend/dispatcher.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index dac7498..a5349e6 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -187,6 +187,7 @@ class Worker(multiprocessing.Process):
ip = self.spawn_instance()
if not ip:
raise errors.CoprWorkerError, "No IP found from creating instance"
+ self.ip = ip
except ansible.errors.AnsibleError, e:
self.callback.log('failure to setup instance: %s' % e)
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 452080a9c849b46663760d0a7c67383f25121a94
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Fri Nov 30 11:36:00 2012 -0500
move to shutil.move not os.rename b/c of mount boundaries
>---------------------------------------------------------------
backend/dispatcher.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index 8b47c70..dac7498 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -3,6 +3,7 @@
import os
import sys
+import shutil
import multiprocessing
import time
import Queue
@@ -101,6 +102,7 @@ class Worker(multiprocessing.Process):
self.callback.log('creating worker: %s' % ip)
def spawn_instance(self):
+ """call the spawn playbook to startup/provision a building instance"""
self.callback.log('spawning instance begin')
stats = callbacks.AggregateStats()
@@ -124,6 +126,7 @@ class Worker(multiprocessing.Process):
return None
def terminate_instance(self):
+ """call the terminate playbook to destroy the building instance"""
self.callback.log('terminate instance begin')
stats = callbacks.AggregateStats()
@@ -154,9 +157,10 @@ class Worker(multiprocessing.Process):
return jobdata
def return_results(self, job):
+ """write out a completed json file to the results dir and submit the results to the frontend"""
self.callback.log('%s status %s. Took %s seconds' % (job.build_id, job.status, job.ended_on - job.started_on))
jobfilename = os.path.basename(job.jobfile)
- os.rename(job.jobfile, job.destdir + '/' + jobfilename)
+ shutil.move(job.jobfile, job.destdir + '/' + jobfilename)
#FIXME - this should either return job status/results
# into a queue or it should submit results directly to the frontend
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 23ceef0bdc9cd7adedfe81f03b4292bdbc1c924a
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Fri Nov 30 10:55:23 2012 -0500
terminate instances when the build finishes
>---------------------------------------------------------------
backend/dispatcher.py | 21 ++++++++++++++++-----
backend/mockremote.py | 5 +++++
copr-be.py | 3 ++-
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index ef621be..c9b34e9 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -108,7 +108,7 @@ class Worker(multiprocessing.Process):
runner_cb = callbacks.DefaultRunnerCallbacks()
# fixme - extra_vars to include ip as a var if we need to specify ips
# also to include info for instance type to handle the memory requirements of builds
- play = ansible.playbook.PlayBook(stats=stats, playbook=self.opts.playbook,
+ play = ansible.playbook.PlayBook(stats=stats, playbook=self.opts.spawn_playbook,
callbacks=playbook_cb, runner_callbacks=runner_cb,
remote_user='root')
@@ -123,6 +123,19 @@ class Worker(multiprocessing.Process):
return i
return None
+ def terminate_instance(self):
+ self.callback.log('terminate instance begin')
+
+ stats = callbacks.AggregateStats()
+ playbook_cb = SilentPlaybookCallbacks(verbose=False)
+ runner_cb = callbacks.DefaultRunnerCallbacks()
+ play = ansible.playbook.PlayBook(host_list=[self.ip], stats=stats, playbook=self.opts.terminate_playbook,
+ callbacks=playbook_cb, runner_callbacks=runner_cb,
+ remote_user='root')
+
+ play.run()
+ self.callback.log('terminate instance end')
+
def parse_job(self, jobfile):
# read the json of the job in
# break out what we need return a bunch of the info we need
@@ -205,8 +218,6 @@ class Worker(multiprocessing.Process):
job.status = status
self.return_results(job)
self.callback.log('worker finished build: %s' % ip)
- # FIXME call terminate on the instance
-
-
-
+ # clean up the instance
+ self.terminate_instance()
diff --git a/backend/mockremote.py b/backend/mockremote.py
index 7a48857..5bfb1f2 100755
--- a/backend/mockremote.py
+++ b/backend/mockremote.py
@@ -482,6 +482,11 @@ class MockRemote(object):
self.callback.end_download(pkg)
+ # FIXME
+ # need a plugin hook or some mechanism to check random
+ # info about the pkgs
+
+
# checking where to stick stuff
if not b_status:
if self.recurse:
diff --git a/copr-be.py b/copr-be.py
index d638ddd..0d20e20 100644
--- a/copr-be.py
+++ b/copr-be.py
@@ -55,7 +55,8 @@ class CoprBackend(object):
opts.results_baseurl = _get_conf(cp,'backend', 'results_baseurl', 'http://copr')
opts.frontend_url = _get_conf(cp, 'backend', 'frontend_url', 'http://coprs/rest/api')
opts.frontend_auth = _get_conf(cp,'backend', 'frontend_auth', 'PASSWORDHERE')
- opts.playbook = _get_conf(cp,'backend','playbook', '/etc/copr/builder_playbook.yml')
+ opts.spawn_playbook = _get_conf(cp,'backend','spawn_playbook', '/etc/copr/builder_playbook.yml')
+ opts.terminate_playbook = _get_conf(cp,'backend','terminate_playbook', '/etc/copr/terminate_playbook.yml')
opts.jobsdir = _get_conf(cp, 'backend', 'jobsdir', None)
opts.destdir = _get_conf(cp, 'backend', 'destdir', None)
opts.sleeptime = int(_get_conf(cp, 'backend', 'sleeptime', 10))