[copr] master: [backend] handle "delete" action (f5dba4e)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit f5dba4e3b55d61a94a4d1e8462b6af73cce971f1
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Nov 13 12:18:39 2013 +0100
[backend] handle "delete" action
>---------------------------------------------------------------
backend/actions.py | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/backend/actions.py b/backend/actions.py
index 079d986..31e2fc6 100644
--- a/backend/actions.py
+++ b/backend/actions.py
@@ -1,4 +1,8 @@
+from bunch import Bunch
from callback import FrontendCallback
+import os.path
+import shutil
+import time
class Action(object):
""" Object to send data back to fronted """
@@ -6,14 +10,29 @@ class Action(object):
def __init__(self, opts, events, action):
super(Action, self).__init__()
self.frontend_callback = FrontendCallback(opts)
+ self.destdir = opts.destdir
self.data = action
self.events = events
+ def event(self, what):
+ self.events.put({'when':time.time(), 'who':'action', 'what':what})
+
def run(self):
""" Handle action (other then builds) - like rename or delete of project """
+ result = Bunch()
+ result.id = self.data['id']
if self.data['action_type'] == 0: # delete
- self.events("Action delete")
+ self.event("Action delete")
+ project = self.data['old_value']
+ path = os.path.normpath(self.destdir + '/' + project)
+ if os.path.exists(path):
+ self.events('Removing %s' % path)
+ shutil.rmtree(path)
+ result.job_ended_on = time.time()
+ result.result = 1 # success
elif self.data['action_type'] == 1: # rename
- self.events("Action rename")
+ self.event("Action rename")
elif self.data['action_type'] == 2: # legal-flag
- self.events("Action legal-flag: ignoring")
+ self.event("Action legal-flag: ignoring")
+ if 'result' in result:
+ self.frontend_callback.post_to_frontend(result)
10 years, 7 months
[copr] master: base handling of actions (215d781)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 215d781f023d188e795cddebd4bab3d7cbd0d067
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 12 15:51:52 2013 +0100
base handling of actions
without real handlers for each action. just fundations for now
>---------------------------------------------------------------
backend/actions.py | 19 +++++++++++++++++++
copr-be.py | 7 ++++++-
2 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/backend/actions.py b/backend/actions.py
new file mode 100644
index 0000000..079d986
--- /dev/null
+++ b/backend/actions.py
@@ -0,0 +1,19 @@
+from callback import FrontendCallback
+
+class Action(object):
+ """ Object to send data back to fronted """
+
+ def __init__(self, opts, events, action):
+ super(Action, self).__init__()
+ self.frontend_callback = FrontendCallback(opts)
+ self.data = action
+ self.events = events
+
+ def run(self):
+ """ Handle action (other then builds) - like rename or delete of project """
+ if self.data['action_type'] == 0: # delete
+ self.events("Action delete")
+ elif self.data['action_type'] == 1: # rename
+ self.events("Action rename")
+ elif self.data['action_type'] == 2: # legal-flag
+ self.events("Action legal-flag: ignoring")
diff --git a/copr-be.py b/copr-be.py
index a9d3314..15290c7 100755
--- a/copr-be.py
+++ b/copr-be.py
@@ -3,6 +3,7 @@
from backend import errors
from backend.dispatcher import Worker
+from backend.actions import Action
from bunch import Bunch
import ConfigParser
import daemon
@@ -67,6 +68,11 @@ class CoprJobGrab(multiprocessing.Process):
self.event('Wrote job: %s' % b['id'])
if count:
self.event('New jobs: %s' % count)
+ if 'actions' in r_json and r_json['actions']:
+ self.event('%s actions returned' % len(r_json['actions']))
+ for action in r_json['actions']:
+ ao = Action(self.opts, self.events, action)
+ ao.run()
def run(self):
abort = False
@@ -80,7 +86,6 @@ class CoprJobGrab(multiprocessing.Process):
self.event('adding to work queue id %s' % n)
time.sleep(self.opts.sleeptime)
-
class CoprLog(multiprocessing.Process):
"""log mechanism where items from the events queue get recorded"""
def __init__(self, opts, events):
10 years, 7 months
[copr] master: move callback to frontend to separate object (3e123e7)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 3e123e787055362baadd64f924c6df7e9d50fe7a
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 12 16:48:23 2013 +0100
move callback to frontend to separate object
>---------------------------------------------------------------
backend/callback.py | 32 ++++++++++++++++++++++++++++++++
backend/dispatcher.py | 25 ++++++-------------------
2 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/backend/callback.py b/backend/callback.py
new file mode 100644
index 0000000..165a0eb
--- /dev/null
+++ b/backend/callback.py
@@ -0,0 +1,32 @@
+import json
+import requests
+
+class FrontendCallback(object):
+ """ Object to send data back to fronted """
+
+ def __init__(self, opts):
+ super(FrontendCallback, self).__init__()
+ self.frontend_url = opts.frontend_url
+ self.frontend_auth = opts.frontend_auth
+ self.msg = None
+
+ def post_to_frontend(self, data):
+ """ Send data to frontend """
+ headers = {'content-type': 'application/json'}
+ url = '%s/update_actions/' % self.frontend_url
+ auth = ('user', self.frontend_auth)
+
+ self.msg = None
+ try:
+ r = requests.post(url, data=json.dumps(data), auth=auth,
+ headers=headers)
+ if r.status_code != 200:
+ self.msg = 'Failed to submit to frontend: %s: %s' % (r.status_code, r.text)
+ except requests.RequestException, e:
+ self.msg = 'Post request failed: %s' % e
+
+ if self.msg:
+ return False
+ else:
+ return True
+
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index f5a5d7b..d0dc157 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -5,6 +5,7 @@ import time
import Queue
import json
import mockremote
+from callback import FrontendCallback
from bunch import Bunch
import errors
import ansible
@@ -97,6 +98,7 @@ class Worker(multiprocessing.Process):
self.kill_received = False
self.callback = callback
self.create = create
+ self.frontend_callback = FrontendCallback(opts)
if not self.callback:
self.logfile = self.opts.worker_logdir + '/worker-%s.log' % self.worker_num
self.callback = WorkerCallback(logfile = self.logfile)
@@ -221,25 +223,10 @@ class Worker(multiprocessing.Process):
# maybe we move this to the callback?
def post_to_frontend(self, data):
"""send data to frontend"""
-
- headers = {'content-type': 'application/json'}
- url='%s/update_actions/' % self.opts.frontend_url
- auth=('user', self.opts.frontend_auth)
-
- msg = None
- try:
- r = requests.post(url, data=json.dumps(data), auth=auth,
- headers=headers)
- if r.status_code != 200:
- msg = 'Failed to submit to frontend: %s: %s' % (r.status_code, r.text)
- except requests.RequestException, e:
- msg = 'Post request failed: %s' % e
-
- if msg:
- self.callback.log(msg)
- return False
-
- return True
+ result = self.frontend_callback.post_to_frontend(data)
+ if not result:
+ self.callback.log(self.frontend_callback.msg)
+ return result
# maybe we move this to the callback?
def mark_started(self, job):
10 years, 7 months
[copr] master: secure waiting_actions with password (380e643)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 380e643631b529f96042468daf6fd95b24f2af58
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 12 15:00:04 2013 +0100
secure waiting_actions with password
>---------------------------------------------------------------
copr-be.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/copr-be.py b/copr-be.py
index 961384b..a9d3314 100755
--- a/copr-be.py
+++ b/copr-be.py
@@ -45,7 +45,7 @@ class CoprJobGrab(multiprocessing.Process):
def fetch_jobs(self):
try:
- r = requests.get('%s/waiting_actions/' % self.opts.frontend_url) # auth stuff here? maybe/maybenot
+ r = requests.get('%s/waiting_actions/' % self.opts.frontend_url, auth=('user', self.opts.frontend_auth))
except requests.RequestException, e:
self.event('Error retrieving jobs from %s: %s' % (self.opts.frontend_url, e))
else:
10 years, 7 months
[copr] master: pick only individual builds (9a781ef)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 9a781ef7b77c22cbbc1034aaa2c075b55c8e26c7
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 12 14:54:18 2013 +0100
pick only individual builds
this assume changes in frontend which rmarko have in progress right now
>---------------------------------------------------------------
backend/dispatcher.py | 44 +++++++++++++++++++++-----------------------
copr-be.py | 2 +-
2 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index c23d02d..f5a5d7b 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -223,7 +223,7 @@ class Worker(multiprocessing.Process):
"""send data to frontend"""
headers = {'content-type': 'application/json'}
- url='%s/update_builds/' % self.opts.frontend_url
+ url='%s/update_actions/' % self.opts.frontend_url
auth=('user', self.opts.frontend_auth)
msg = None
@@ -320,24 +320,23 @@ class Worker(multiprocessing.Process):
build=job.build_id, ip=ip, pid=self.pid)
self.event('build.start', template, content)
- for chroot in job.chroots:
- template = 'chroot start: chroot:{chroot} user:{user} copr:{copr} build:{build} ip:{ip} pid:{pid}'
- content = dict(chroot=chroot, user=job.user_name,
- copr=job.copr_name, build=job.build_id,
- ip=ip, pid=self.pid)
- self.event('chroot.start', template, content)
-
- chroot_destdir = os.path.normpath(job.destdir + '/' + chroot)
- # setup our target dir locally
- if not os.path.exists(chroot_destdir):
- try:
- os.makedirs(chroot_destdir)
- except (OSError, IOError), e:
- msg = "Could not make results dir for job: %s - %s" % (chroot_destdir, str(e))
- self.callback.log(msg)
- status = 0
- continue
+ template = 'chroot start: chroot:{chroot} user:{user} copr:{copr} build:{build} ip:{ip} pid:{pid}'
+ content = dict(chroot=job.chroot, user=job.user_name,
+ copr=job.copr_name, build=job.build_id,
+ ip=ip, pid=self.pid)
+ self.event('chroot.start', template, content)
+
+ chroot_destdir = os.path.normpath(job.destdir + '/' + job.chroot)
+ # setup our target dir locally
+ if not os.path.exists(chroot_destdir):
+ try:
+ os.makedirs(chroot_destdir)
+ except (OSError, IOError), e:
+ msg = "Could not make results dir for job: %s - %s" % (chroot_destdir, str(e))
+ self.callback.log(msg)
+ status = 0
+ if status == 1:
# FIXME
# need a plugin hook or some mechanism to check random
# info about the pkgs
@@ -345,15 +344,14 @@ class Worker(multiprocessing.Process):
# and run a series of checks on the package before we
# start the build - most importantly license checks.
-
- self.callback.log('Starting build: id=%r builder=%r timeout=%r destdir=%r chroot=%r repos=%r' % (job.build_id,ip, job.timeout, job.destdir, chroot, str(job.repos)))
+ self.callback.log('Starting build: id=%r builder=%r timeout=%r destdir=%r chroot=%r repos=%r' % (job.build_id,ip, job.timeout, job.destdir, job.chroot, str(job.repos)))
self.callback.log('building pkgs: %s' % ' '.join(job.pkgs))
try:
chroot_repos = list(job.repos)
- chroot_repos.append(job.results + '/' + chroot)
+ chroot_repos.append(job.results + '/' + job.chroot)
chrootlogfile = chroot_destdir + '/build-%s.log' % job.build_id
mr = mockremote.MockRemote(builder=ip, timeout=job.timeout,
- destdir=job.destdir, chroot=chroot, cont=True, recurse=True,
+ destdir=job.destdir, chroot=job.chroot, cont=True, recurse=True,
repos=chroot_repos,
callback=mockremote.CliLogCallBack(quiet=True,logfn=chrootlogfile))
mr.build_pkgs(job.pkgs)
@@ -366,7 +364,7 @@ class Worker(multiprocessing.Process):
# check if any pkgs didn't build
if mr.failed:
status = 0
- self.callback.log('Finished build: id=%r builder=%r timeout=%r destdir=%r chroot=%r repos=%r' % (job.build_id, ip, job.timeout, job.destdir, chroot, str(job.repos)))
+ self.callback.log('Finished build: id=%r builder=%r timeout=%r destdir=%r chroot=%r repos=%r' % (job.build_id, ip, job.timeout, job.destdir, job.chroot, str(job.repos)))
job.ended_on = time.time()
job.status = status
diff --git a/copr-be.py b/copr-be.py
index e1d8da3..961384b 100755
--- a/copr-be.py
+++ b/copr-be.py
@@ -45,7 +45,7 @@ class CoprJobGrab(multiprocessing.Process):
def fetch_jobs(self):
try:
- r = requests.get('%s/waiting_builds/' % self.opts.frontend_url) # auth stuff here? maybe/maybenot
+ r = requests.get('%s/waiting_actions/' % self.opts.frontend_url) # auth stuff here? maybe/maybenot
except requests.RequestException, e:
self.event('Error retrieving jobs from %s: %s' % (self.opts.frontend_url, e))
else:
10 years, 7 months
[copr] master: make address, where we send legal flags, configurable (9eb705d)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 9eb705d708cd20688f132a99a9dc6a0ffd880606
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 12 13:35:58 2013 +0100
make address, where we send legal flags, configurable
>---------------------------------------------------------------
coprs_frontend/config/copr.conf | 3 +++
coprs_frontend/coprs/config.py | 2 ++
.../coprs/views/coprs_ns/coprs_general.py | 6 ++++--
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/coprs_frontend/config/copr.conf b/coprs_frontend/config/copr.conf
index 9c61113..e608897 100644
--- a/coprs_frontend/config/copr.conf
+++ b/coprs_frontend/config/copr.conf
@@ -25,6 +25,9 @@ SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://copr-fe:coprpass@/coprdb'
#SEND_LOGS_TO = ['root@localhost']
#LOGGING_LEVEL = logging.ERROR
+# where to send notice about raised legal flag
+#SEND_LEGAL_TO = ['root@localhost', 'somebody(a)somewhere.com']
+
DEBUG = False
SQLALCHEMY_ECHO = False
diff --git a/coprs_frontend/coprs/config.py b/coprs_frontend/coprs/config.py
index a84cee6..260bb72 100644
--- a/coprs_frontend/coprs/config.py
+++ b/coprs_frontend/coprs/config.py
@@ -26,6 +26,8 @@ class Config(object):
SEND_LOGS_TO = ['root@localhost']
LOGGING_LEVEL = logging.ERROR
+ SEND_LEGAL_TO = ['root@localhost']
+
class ProductionConfig(Config):
DEBUG = False
#SECRET_KEY = 'put_some_secret_here'
diff --git a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
index 15ba2f9..f8be424 100644
--- a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
+++ b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
@@ -7,6 +7,7 @@ import sqlalchemy
import urlparse
from email.mime.text import MIMEText
+from coprs import app
from coprs import db
from coprs import exceptions
from coprs import forms
@@ -284,6 +285,7 @@ def copr_legal_flag(username, coprname):
db.session.add(legal_flag)
db.session.commit()
+ send_to = app.config['SEND_LEGAL_TO'] or ['root@localhost']
hostname = platform.node()
navigate_to = "\nNavigate to http://%s%s" % (hostname, flask.url_for('admin_ns.legal_flag'))
contact = "\nContact on owner is: %s <%s>" % (username, copr.owner.mail)
@@ -291,9 +293,9 @@ def copr_legal_flag(username, coprname):
msg = MIMEText(form.comment.data + navigate_to + contact + reported_by)
msg['Subject'] = 'Legal flag raised on %s' % coprname
msg['From'] = 'root@%s' % hostname
- msg['To'] = 'root@localhost'
+ msg['To'] = ', '.join(send_to)
s = smtplib.SMTP('localhost')
- s.sendmail('root@%s' % hostname, ['root'], msg.as_string())
+ s.sendmail('root@%s' % hostname, send_to, msg.as_string())
s.quit()
flask.flash('Admin was noticed about your report and will investigate the project shortly.')
10 years, 7 months
[copr] master: send email to root after legal flag have been raised (88aa0c6)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 88aa0c67a8d6a79f3f924a8c025738934b9a79be
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 12 11:01:32 2013 +0100
send email to root after legal flag have been raised
>---------------------------------------------------------------
.../coprs/views/coprs_ns/coprs_general.py | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
index e3030ea..15ba2f9 100644
--- a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
+++ b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
@@ -1,8 +1,11 @@
import time
import flask
+import platform
+import smtplib
import sqlalchemy
import urlparse
+from email.mime.text import MIMEText
from coprs import db
from coprs import exceptions
@@ -280,6 +283,19 @@ def copr_legal_flag(username, coprname):
reporter=flask.g.user)
db.session.add(legal_flag)
db.session.commit()
+
+ hostname = platform.node()
+ navigate_to = "\nNavigate to http://%s%s" % (hostname, flask.url_for('admin_ns.legal_flag'))
+ contact = "\nContact on owner is: %s <%s>" % (username, copr.owner.mail)
+ reported_by = "\nReported by %s <%s>" % (flask.g.user.name, flask.g.user.mail)
+ msg = MIMEText(form.comment.data + navigate_to + contact + reported_by)
+ msg['Subject'] = 'Legal flag raised on %s' % coprname
+ msg['From'] = 'root@%s' % hostname
+ msg['To'] = 'root@localhost'
+ s = smtplib.SMTP('localhost')
+ s.sendmail('root@%s' % hostname, ['root'], msg.as_string())
+ s.quit()
+
flask.flash('Admin was noticed about your report and will investigate the project shortly.')
return flask.redirect(flask.url_for('coprs_ns.copr_detail', username=username, coprname=coprname))
10 years, 7 months
[copr] master: Automatic commit of package [copr] release [1.14-1]. (a39c2c1)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit a39c2c181225621793b5639b4fc69a6979436bb4
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Nov 8 09:29:23 2013 +0100
Automatic commit of package [copr] release [1.14-1].
>---------------------------------------------------------------
copr.spec | 7 ++++++-
rel-eng/packages/copr | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/copr.spec b/copr.spec
index ed28b07..8bbe2c2 100644
--- a/copr.spec
+++ b/copr.spec
@@ -5,7 +5,7 @@
%global modulename copr
Name: copr
-Version: 1.13
+Version: 1.14
Release: 1%{?dist}
Summary: Cool Other Package Repo
@@ -380,6 +380,11 @@ fi
%{_mandir}/man8/%{name}-selinux-relabel.8*
%changelog
+* Fri Nov 08 2013 Miroslav Suchý <msuchy(a)redhat.com> 1.14-1
+- 1028235 - add disclaimer about repos
+- fix pagination
+- fix one failing test
+
* Wed Nov 06 2013 Miroslav Suchý <msuchy(a)redhat.com> 1.13-1
- suggest correct name of repo file
- we could not use releasever macro
diff --git a/rel-eng/packages/copr b/rel-eng/packages/copr
index 1a5ddc2..ed39ca2 100644
--- a/rel-eng/packages/copr
+++ b/rel-eng/packages/copr
@@ -1 +1 @@
-1.13-1 ./
+1.14-1 ./
10 years, 7 months
[copr] master: 1028235 - add disclaimer about repos (42398db)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 42398db5fb0226cd2a1ff5ef411c5578a7e2257e
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Nov 8 09:26:31 2013 +0100
1028235 - add disclaimer about repos
>---------------------------------------------------------------
.../coprs/templates/coprs/detail/overview.html | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/coprs_frontend/coprs/templates/coprs/detail/overview.html b/coprs_frontend/coprs/templates/coprs/detail/overview.html
index 52363a0..9f5fd25 100644
--- a/coprs_frontend/coprs/templates/coprs/detail/overview.html
+++ b/coprs_frontend/coprs/templates/coprs/detail/overview.html
@@ -10,6 +10,10 @@
<h2>Installation Instructions</h2>
<div class="shift-right">{{ copr.instructions_or_not_filled}}</div>
<h2>Active Releases</h2>
+ <div class="disclaimer">
+ The following unofficial repositories are provided as-is by owner of this project.
+ Contact the owner directly for bugs or issues (IE: not bugzilla).
+ </div>
<table class="releases">
<tr>
<th class="leftmost">Release</th>
10 years, 7 months