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
changes/56/554056/13
Monty Taylor 3 years ago
committed by Tobias Henkel
parent
commit
8211320665
No known key found for this signature in database GPG Key ID: 3750DEC158E5FA2
4 changed files with 55 additions and 1 deletions
  1. +7
    -0
      releasenotes/notes/change-missing-build-url-6df030ae3d8793ae.yaml
  2. +41
    -0
      zuul/driver/sql/alembic/versions/52d49e1bfe22_change_missing_build_url_to_null.py
  3. +1
    -1
      zuul/model.py
  4. +6
    -0
      zuul/reporter/__init__.py

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

@ -0,0 +1,7 @@
---
upgrade:
- |
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/52d49e1bfe22_change_missing_build_url_to_null.py 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
#
# 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.
"""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=''):
op.execute(
'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/model.py 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 job.name
url = default_url or build.url or None
return (result, url)
def formatJSON(self, websocket_url=None):


+ 6
- 0
zuul/reporter/__init__.py View File

@ -251,6 +251,12 @@ class BaseReporter(object, metaclass=abc.ABCMeta):
else:
error = ''
name = job.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 job.name
jobs_fields.append((name, url, result, error, elapsed, voting))
return jobs_fields


Loading…
Cancel
Save