Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
commit 23ceef0bdc9cd7adedfe81f03b4292bdbc1c924a Author: Seth Vidal skvidal@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))
copr-devel@lists.fedorahosted.org