track start time for tasks
This commit is contained in:
parent
ee5423221f
commit
e78783ff8f
5 changed files with 21 additions and 2 deletions
5
cli/koji
5
cli/koji
|
|
@ -3224,6 +3224,11 @@ def _printTaskInfo(session, task_id, level=0, recurse=True, verbose=True):
|
|||
print "%s %s" % (indent, line)
|
||||
print "%sOwner: %s" % (indent, owner)
|
||||
print "%sState: %s" % (indent, koji.TASK_STATES[info['state']].lower())
|
||||
print "%sCreated: %s" % (indent, time.asctime(time.localtime(info['create_ts'])))
|
||||
if info.get('start_ts'):
|
||||
print "%sStarted: %s" % (indent, time.asctime(time.localtime(info['start_ts'])))
|
||||
if info.get('completion_ts'):
|
||||
print "%sFinished: %s" % (indent, time.asctime(time.localtime(info['completion_ts'])))
|
||||
if host_info:
|
||||
print "%sHost: %s" % (indent, host_info['name'])
|
||||
if build_info:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ BEGIN;
|
|||
-- First the simple stuff. A pair of new host fields.
|
||||
ALTER TABLE host ADD COLUMN description TEXT;
|
||||
ALTER TABLE host ADD COLUMN comment TEXT;
|
||||
-- ...and a new field for tasks
|
||||
ALTER TABLE task ADD COLUMN start_time TIMESTAMP;
|
||||
|
||||
|
||||
-- The rest updates all the versioned tables to track who did what
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ CREATE TABLE task (
|
|||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
state INTEGER,
|
||||
create_time TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
start_time TIMESTAMP,
|
||||
completion_time TIMESTAMP,
|
||||
channel_id INTEGER NOT NULL REFERENCES channels(id),
|
||||
host_id INTEGER REFERENCES host (id),
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ class Task(object):
|
|||
('task.state', 'state'),
|
||||
('task.create_time', 'create_time'),
|
||||
('EXTRACT(EPOCH FROM create_time)','create_ts'),
|
||||
('task.start_time', 'start_time'),
|
||||
('EXTRACT(EPOCH FROM task.start_time)', 'start_ts'),
|
||||
('task.completion_time', 'completion_time'),
|
||||
('EXTRACT(EPOCH FROM completion_time)','completion_ts'),
|
||||
('task.channel_id', 'channel_id'),
|
||||
|
|
@ -186,10 +188,15 @@ class Task(object):
|
|||
|
||||
returns task data if successful, None otherwise"""
|
||||
if self.lock(host_id,'OPEN'):
|
||||
#set task start time
|
||||
update = UpdateProcessor('task', clauses=['id=%(id)i'], values=vars(self))
|
||||
update.rawset(start_time='NOW()')
|
||||
update.execute()
|
||||
# get more complete data to return
|
||||
fields = self.fields + (('task.request', 'request'),)
|
||||
q = """SELECT %s FROM task WHERE id=%%(id)i""" % ','.join([f[0] for f in fields])
|
||||
ret = _singleRow(q, vars(self), [f[1] for f in fields], strict=True)
|
||||
query = QueryProcessor(tables=['task'], clauses=['id=%(id)i'], values=vars(self),
|
||||
columns=[f[0] for f in fields], aliases=[f[1] for f in fields])
|
||||
ret = query.executeOne()
|
||||
if ret['request'].find('<?xml', 0, 10) == -1:
|
||||
#handle older base64 encoded data
|
||||
ret['request'] = base64.decodestring(ret['request'])
|
||||
|
|
|
|||
|
|
@ -199,6 +199,10 @@
|
|||
<tr>
|
||||
<th>Created</th><td>$util.formatTimeLong($task.create_time)</td>
|
||||
</tr>
|
||||
#if $task.start_time
|
||||
<tr>
|
||||
<th>Started</th><td>$util.formatTimeLong($task.start_time)</td>
|
||||
#end if
|
||||
#if $task.state == $koji.TASK_STATES.OPEN
|
||||
#if $estCompletion
|
||||
<tr>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue