Store event id for buildsets in database
Having the zuul event id available in the database and also in the build and buildset detail page makes debugging a lot easier. Change-Id: Ia1e4aaf50fb28bb27cbcfcfc3b5a92bba88fc85e
This commit is contained in:
parent
938ca7b8b4
commit
e58e8224c0
|
@ -74,7 +74,7 @@ class TestSQLConnection(ZuulDBTestCase):
|
|||
buildset_table = table_prefix + 'zuul_buildset'
|
||||
build_table = table_prefix + 'zuul_build'
|
||||
|
||||
self.assertEqual(15, len(insp.get_columns(buildset_table)))
|
||||
self.assertEqual(16, len(insp.get_columns(buildset_table)))
|
||||
self.assertEqual(10, len(insp.get_columns(build_table)))
|
||||
|
||||
def test_sql_tables_created(self):
|
||||
|
@ -149,6 +149,7 @@ class TestSQLConnection(ZuulDBTestCase):
|
|||
self.assertEqual(
|
||||
'https://review.example.com/%d' % buildset0['change'],
|
||||
buildset0['ref_url'])
|
||||
self.assertNotEqual(None, buildset0['event_id'])
|
||||
|
||||
buildset0_builds = conn.execute(
|
||||
sa.sql.select([reporter.connection.zuul_build_table]).where(
|
||||
|
|
|
@ -30,7 +30,7 @@ class Buildset extends React.Component {
|
|||
const { buildset } = this.props
|
||||
const rows = []
|
||||
const myColumns = [
|
||||
'change', 'project', 'branch', 'pipeline', 'result', 'message'
|
||||
'change', 'project', 'branch', 'pipeline', 'result', 'message', 'event_id'
|
||||
]
|
||||
const buildRows = []
|
||||
const buildColumns = [
|
||||
|
@ -47,6 +47,9 @@ class Buildset extends React.Component {
|
|||
</a>
|
||||
)
|
||||
}
|
||||
if (column === 'event_id') {
|
||||
label = 'event id'
|
||||
}
|
||||
if (value) {
|
||||
rows.push({key: label, value: value})
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class Summary extends React.Component {
|
|||
'job_name', 'result', 'buildset', 'voting',
|
||||
'pipeline', 'start_time', 'end_time', 'duration',
|
||||
'project', 'branch', 'change', 'patchset', 'oldrev', 'newrev',
|
||||
'ref', 'new_rev', 'ref_url', 'log_url']
|
||||
'ref', 'new_rev', 'ref_url', 'log_url', 'event_id']
|
||||
|
||||
if (!build.buildset) {
|
||||
// Safely handle missing buildset information
|
||||
|
@ -75,6 +75,9 @@ class Summary extends React.Component {
|
|||
if (column === 'ref_url') {
|
||||
label = 'ref url'
|
||||
}
|
||||
if (column === 'event_id') {
|
||||
label = 'event id'
|
||||
}
|
||||
if (value) {
|
||||
rows.push({key: label, value: value})
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""add event id column
|
||||
|
||||
Revision ID: 5f183546b39c
|
||||
Revises: e0eda5d09eae
|
||||
Create Date: 2019-12-05 13:33:30.155447
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5f183546b39c'
|
||||
down_revision = 'e0eda5d09eae'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade(table_prefix=''):
|
||||
op.add_column(
|
||||
table_prefix + "zuul_buildset",
|
||||
sa.Column("event_id", sa.String(255), nullable=True)
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
raise Exception("Downgrades not supported")
|
|
@ -58,8 +58,8 @@ class DatabaseSession(object):
|
|||
|
||||
def getBuilds(self, tenant=None, project=None, pipeline=None,
|
||||
change=None, branch=None, patchset=None, ref=None,
|
||||
newrev=None, uuid=None, job_name=None, voting=None,
|
||||
node_name=None, result=None, provides=None,
|
||||
newrev=None, event_id=None, uuid=None, job_name=None,
|
||||
voting=None, node_name=None, result=None, provides=None,
|
||||
limit=50, offset=0):
|
||||
|
||||
build_table = self.connection.zuul_build_table
|
||||
|
@ -96,6 +96,7 @@ class DatabaseSession(object):
|
|||
q = self.listFilter(q, buildset_table.c.patchset, patchset)
|
||||
q = self.listFilter(q, buildset_table.c.ref, ref)
|
||||
q = self.listFilter(q, buildset_table.c.newrev, newrev)
|
||||
q = self.listFilter(q, buildset_table.c.event_id, event_id)
|
||||
q = self.listFilter(q, build_table.c.uuid, uuid)
|
||||
q = self.listFilter(q, build_table.c.job_name, job_name)
|
||||
q = self.listFilter(q, build_table.c.voting, voting)
|
||||
|
@ -275,6 +276,7 @@ class SQLConnection(BaseConnection):
|
|||
result = sa.Column(sa.String(255))
|
||||
message = sa.Column(sa.TEXT())
|
||||
tenant = sa.Column(sa.String(255))
|
||||
event_id = sa.Column(sa.String(255), nullable=True)
|
||||
|
||||
def createBuild(self, *args, **kw):
|
||||
session = orm.session.Session.object_session(self)
|
||||
|
|
|
@ -37,6 +37,10 @@ class SQLReporter(BaseReporter):
|
|||
log.warning("SQL reporter (%s) is disabled ", self)
|
||||
return
|
||||
|
||||
event_id = None
|
||||
if item.event is not None:
|
||||
event_id = getattr(item.event, "zuul_event_id", None)
|
||||
|
||||
with self.connection.getSession() as db:
|
||||
db_buildset = db.createBuildSet(
|
||||
uuid=item.current_build_set.uuid,
|
||||
|
@ -52,6 +56,7 @@ class SQLReporter(BaseReporter):
|
|||
zuul_ref=item.current_build_set.ref,
|
||||
ref_url=item.change.url,
|
||||
result=item.current_build_set.result,
|
||||
event_id=event_id,
|
||||
message=self._formatItemReport(item, with_jobs=False),
|
||||
)
|
||||
for job in item.getJobs():
|
||||
|
|
|
@ -833,6 +833,7 @@ class ZuulWebAPI(object):
|
|||
'ref': buildset.ref,
|
||||
'newrev': buildset.newrev,
|
||||
'ref_url': buildset.ref_url,
|
||||
'event_id': buildset.event_id,
|
||||
'buildset': {
|
||||
'uuid': buildset.uuid,
|
||||
},
|
||||
|
@ -909,6 +910,7 @@ class ZuulWebAPI(object):
|
|||
'ref': buildset.ref,
|
||||
'newrev': buildset.newrev,
|
||||
'ref_url': buildset.ref_url,
|
||||
'event_id': buildset.event_id,
|
||||
}
|
||||
if builds:
|
||||
ret['builds'] = []
|
||||
|
|
Loading…
Reference in New Issue