[PATCH] add/use strict option in find_build_id
by Mike McLean
---
hub/kojihub.py | 37 ++++++++++++++-----------------------
1 file changed, 14 insertions(+), 23 deletions(-)
diff --git a/hub/kojihub.py b/hub/kojihub.py
index a6360af..9decf7c 100644
--- a/hub/kojihub.py
+++ b/hub/kojihub.py
@@ -3176,7 +3176,7 @@ def get_user(userInfo=None,strict=False):
raise koji.GenericError, 'invalid type for userInfo: %s' % type(userInfo)
return _singleRow(q,locals(),fields,strict=strict)
-def find_build_id(X):
+def find_build_id(X, strict=False):
if isinstance(X,int) or isinstance(X,long):
return X
elif isinstance(X,str):
@@ -3201,7 +3201,10 @@ def find_build_id(X):
r=c.fetchone()
#log_error("%r" % r )
if not r:
- return None
+ if strict:
+ raise koji.GenericError, 'No matching build found: %r' % X
+ else:
+ return None
return r[0]
def get_build(buildInfo, strict=False):
@@ -3231,12 +3234,9 @@ def get_build(buildInfo, strict=False):
If there is no build matching the buildInfo given, and strict is specified,
raise an error. Otherwise return None.
"""
- buildID = find_build_id(buildInfo)
+ buildID = find_build_id(buildInfo, strict=strict)
if buildID == None:
- if strict:
- raise koji.GenericError, 'No matching build found: %s' % buildInfo
- else:
- return None
+ return None
fields = (('build.id', 'id'), ('build.version', 'version'), ('build.release', 'release'),
('build.epoch', 'epoch'), ('build.state', 'state'), ('build.completion_time', 'completion_time'),
@@ -3475,12 +3475,9 @@ def get_maven_build(buildInfo, strict=False):
"""
fields = ('build_id', 'group_id', 'artifact_id', 'version')
- build_id = find_build_id(buildInfo)
+ build_id = find_build_id(buildInfo, strict=strict)
if not build_id:
- if strict:
- raise koji.GenericError, 'No matching build found: %s' % buildInfo
- else:
- return None
+ return None
query = """SELECT %s
FROM maven_builds
WHERE build_id = %%(build_id)i""" % ', '.join(fields)
@@ -3498,12 +3495,9 @@ def get_win_build(buildInfo, strict=False):
"""
fields = ('build_id', 'platform')
- build_id = find_build_id(buildInfo)
+ build_id = find_build_id(buildInfo, strict=strict)
if not build_id:
- if strict:
- raise koji.GenericError, 'No matching build found: %s' % buildInfo
- else:
- return None
+ return None
query = QueryProcessor(tables=('win_builds',), columns=fields,
clauses=('build_id = %(build_id)i',),
values={'build_id': build_id})
@@ -3522,12 +3516,9 @@ def get_image_build(buildInfo, strict=False):
Returns a map containing the following keys:
build_id: id of the build
"""
- build_id = find_build_id(buildInfo)
+ build_id = find_build_id(buildInfo, strict=strict)
if not build_id:
- if strict:
- raise koji.GenericError, 'No matching build found: %s' % buildInfo
- else:
- return None
+ return None
query = QueryProcessor(tables=('image_builds',), columns=('build_id',),
clauses=('build_id = %(build_id)i',),
values={'build_id': build_id})
@@ -8268,7 +8259,7 @@ class RootExports(object):
If no build has the given ID, or the build generated no RPMs, an empty list is returned."""
if not isinstance(build, int):
#lookup build id
- build = self.findBuildID(build)
+ build = self.findBuildID(build, strict=True)
return self.listRPMs(buildID=build)
getRPM = staticmethod(get_rpm)
--
1.9.3
8 years
Koji running on RHEL / CentOS 7
by Allen Hewes
Hi,
I am trying to move from Koji 1.9.0 on RHEL 5.11 to Koji 1.9.0 (gitcd45e886) on CentOS 7. But it didn't help my issue:
Testing out the new Koji instance with a task submission:
$ koji --debug regen-repo el5-decisiv
successfully connected to hub
Warning: el5-decisiv is not a build tag
Warning: tag el5-decisiv has an empty arch list Regenerating repo for tag el5-decisiv Watching tasks (this may be safely interrupted)...
30 newRepo (el5-decisiv): open (koji.decisiv.net) Traceback (most recent call last):
File "/usr/bin/koji", line 6566, in <module>
rv = locals()[command].__call__(options, session, args)
File "/usr/bin/koji", line 6410, in handle_regen_repo
return watch_tasks(session, [task_id], quiet=options.quiet)
File "/usr/bin/koji", line 472, in watch_tasks
changed = task.update()
File "/usr/bin/koji", line 377, in update
self.info = self.session.getTaskInfo(self.id, request=True)
File "/usr/lib/python2.7/site-packages/koji/__init__.py", line 1556, in __call__
return self.__func(self.__name,args,opts)
File "/usr/lib/python2.7/site-packages/koji/__init__.py", line 1899, in _callMethod
return self._sendCall(handler, headers, request)
File "/usr/lib/python2.7/site-packages/koji/__init__.py", line 1810, in _sendCall
return self._sendOneCall(handler, headers, request)
File "/usr/lib/python2.7/site-packages/koji/__init__.py", line 1830, in _sendOneCall
response = cnx.getresponse()
File "/usr/lib64/python2.7/httplib.py", line 1045, in getresponse
response.begin()
File "/usr/lib64/python2.7/httplib.py", line 409, in begin
version, status, reason = self._read_status()
File "/usr/lib64/python2.7/httplib.py", line 365, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/usr/lib64/python2.7/socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
File "/usr/lib/python2.7/site-packages/koji/ssl/SSLConnection.py", line 140, in recv
return con.recv(bufsize, flags)
OpenSSL.SSL.SysCallError: (-1, 'Unexpected EOF')
I added a rescue of SSL.SysCallError in the recv() function in /usr/lib/python2.7/site-packages/koji/ssl/SSLConnection.py:
diff -uab /usr/lib/python2.7/site-packages/koji/ssl/SSLConnection.py /usr/lib/python2.7/site-packages/koji/ssl/SSLConnection.py.b
--- /usr/lib/python2.7/site-packages/koji/ssl/SSLConnection.py 2015-01-29 04:00:08.000000000 +0000
+++ /usr/lib/python2.7/site-packages/koji/ssl/SSLConnection.py.b 2015-01-29 04:00:56.224059850 +0000
@@ -138,6 +138,11 @@
try:
return con.recv(bufsize, flags)
+ except SSL.SysCallError as e:
+ if e.args == (-1, 'Unexpected EOF'):
+ break
+ else:
+ raise
except SSL.ZeroReturnError:
return None
except SSL.WantReadError:
Which then the task submission succeeds:
$ koji --debug regen-repo el5-decisiv
successfully connected to hub
Warning: el5-decisiv is not a build tag
Warning: tag el5-decisiv has an empty arch list Regenerating repo for tag el5-decisiv Watching tasks (this may be safely interrupted)...
32 newRepo (el5-decisiv): free
32 newRepo (el5-decisiv): free -> closed
0 free 0 open 1 done 0 failed
32 newRepo (el5-decisiv) completed successfully
I couldn't find a Koji ticket for this error so I don't know if I am making it worse or what I added is Good Enough to use? Is this a known issue?
I also had to install a newer createrepo. I was getting the mergerepo error here:
https://bugzilla.redhat.com/show_bug.cgi?id=1058975
Maybe createrepo should be updated for EPEL 7?
/allen
________________________________
Disclaimer Confidentiality Notice: This e-mail, and any attachments and/or documents linked to this email, are intended for the addressee and may contain information that is privileged, confidential, proprietary, or otherwise protected by law. Any dissemination, distribution, or copying is prohibited. This notice serves as a confidentiality marking for the purpose of any confidentiality or nondisclosure agreement. If you have received this communication in error, please contact the original sender.
8 years
[PATCH] get statistics of tasksbyuser by a single XMLRPC call
by Chenxiong Qi
From: Chenxiong Qi <cqi(a)redhat.com>
This gives better performance to get statistics of tasks by user.
---
hub/kojihub.py | 9 +++++++++
www/kojiweb/index.py | 7 ++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/hub/kojihub.py b/hub/kojihub.py
index f794d5d..b0f7e65 100644
--- a/hub/kojihub.py
+++ b/hub/kojihub.py
@@ -9338,6 +9338,15 @@ class RootExports(object):
values=locals(), opts=queryOpts)
return query.iterate()
+ def reportTasksByUser(self):
+ """Report of tasks by user"""
+ fields = ('owner', 'tasks_count')
+ sql = '''
+SELECT owner, COUNT(id) AS tasks_count
+FROM task GROUP BY owner ORDER BY owner'''
+ rows = _multiRow(sql, None, fields)
+ return dict(((str(row['owner']), row['tasks_count']) for row in rows))
+
class BuildRoot(object):
diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py
index ff15a5f..45a4941 100644
--- a/www/kojiweb/index.py
+++ b/www/kojiweb/index.py
@@ -1986,13 +1986,10 @@ def tasksbyuser(environ, start=None, order='-tasks'):
maxTasks = 1
users = server.listUsers()
+ data = server.reportTasksByUser()
- server.multicall = True
for user in users:
- server.listTasks(opts={'owner': user['id']}, queryOpts={'countOnly': True})
- taskCounts = server.multiCall()
-
- for user, [numTasks] in zip(users, taskCounts):
+ numTasks = data.get(str(user['id']), 0)
user['tasks'] = numTasks
if numTasks > maxTasks:
maxTasks = numTasks
--
1.7.1
8 years
Exporting existing environment variables into mock
by Arun SAG
My build environment (jenkins) has an environment variable named
'BUILD_NUMBER', i want it to be available as a macro. To achieve this
i have added something like this to my mock configuration file
config_opts['macros']['%build_number'] = os.getenv('BUILD_NUMBER') if
os.getenv('BUILD_NUMBER') != None else time.strftime('%d%m%Y%I%M')
But, this os.getenv('BUILD_NUMBER') always returns 'None'. The
environment variable which is available outside mock never gets
exported to mock environment. My mock version is 1.2.7.
--
Arun S A G
http://zer0c00l.in/
8 years