Browse Source

Stop falling back to job name for missing url

We set url to the job name if it's missing, but a job name is not a url
nor is it additional information. Then, in dashboard displays
we have display code that sets url to null if it matches the job name.

Instead of fixing the data at the display layer, let's set it to null in
the first place. So that we can update the dashboard code to remove the
workarounds, let's also run a migration to update the previously saved
build data.

Change-Id: I80ce26de4abc15720d7e37aee73049423584d1b9
Monty Taylor 3 years ago
committed by Tobias Henkel
No known key found for this signature in database GPG Key ID: 3750DEC158E5FA2
4 changed files with 55 additions and 1 deletions
  1. +7
  2. +41
  3. +1
  4. +6

+ 7
- 0
releasenotes/notes/change-missing-build-url-6df030ae3d8793ae.yaml View File

@ -0,0 +1,7 @@
- |
Previously the SqlReporter would record the job name in the database in
place of the url if the url was empty. This has now been updated to store
a null in the database for that case. Zuul will automatically run a
database migration to correct old values.

+ 41
- 0
zuul/driver/sql/alembic/versions/ View File

@ -0,0 +1,41 @@
# Copyright 2018 Red Hat, Inc.
# 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
# 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.
"""Change missing build url to null
Revision ID: 52d49e1bfe22
Revises: e0eda5d09eae
Create Date: 2018-03-18 09:30:23.343650
# revision identifiers, used by Alembic.
revision = '52d49e1bfe22'
down_revision = '32e28a297c3e'
branch_labels = None
depends_on = None
BUILD_TABLE = 'zuul_build'
from alembic import op
def upgrade(table_prefix=''):
'UPDATE {table_name} SET log_url=NULL WHERE log_url=job_name'.format(
table_name=table_prefix + BUILD_TABLE))
def downgrade(table_prefix=''):
raise Exception("Downgrades not supported")

+ 1
- 1
zuul/ View File

@ -2854,7 +2854,7 @@ class QueueItem(object):
self.log.exception("Error while parsing url for job %s:"
% (job,))
if not url:
url = default_url or build.url or
url = default_url or build.url or None
return (result, url)
def formatJSON(self, websocket_url=None):

+ 6
- 0
zuul/reporter/ View File

@ -251,6 +251,12 @@ class BaseReporter(object, metaclass=abc.ABCMeta):
error = ''
name = + ' '
# TODO(mordred) The gerrit consumption interface depends on
# something existing in the url field and don't have a great
# behavior defined for url being none/missing. Put name into
# the url field to match old behavior until we can deal with
# the gerrit-side piece as well
url = url or
jobs_fields.append((name, url, result, error, elapsed, voting))
return jobs_fields