Merge "Add nodeset to build table"

This commit is contained in:
Zuul 2021-07-16 00:07:55 +00:00 committed by Gerrit Code Review
commit ec275041b9
10 changed files with 63 additions and 25 deletions

View File

@ -44,21 +44,30 @@
failure:
resultsdb_failures: null
- nodeset:
name: test-nodeset
nodes:
- name: test_node
label: test_label
- job:
name: base
parent: null
nodeset:
nodes:
- name: test_node
label: test_label
nodeset: test-nodeset
- job:
name: project-merge
run: playbooks/project-merge.yaml
nodeset:
nodes: []
- job:
name: project-test1
run: playbooks/project-test1.yaml
nodeset:
nodes:
- name: test_node
label: test_label
- job:
name: project-test2

View File

@ -1288,6 +1288,7 @@ class TestBuildInfo(BaseTestWeb):
"project=org/project&"
"project=org/project1").json()
self.assertEqual(len(builds_query), 6)
self.assertEqual(builds_query[0]['nodeset'], 'test-nodeset')
resp = self.get_url("api/tenant/non-tenant/builds")
self.assertEqual(404, resp.status_code)

View File

@ -700,11 +700,8 @@ class Client(zuul.cmd.ZuulApp):
'number': {
'title': 'Number'
},
'node_labels': {
'title': 'Node Labels'
},
'node_name': {
'title': 'Node Name'
'nodeset': {
'title': 'Nodeset'
},
'worker.name': {
'title': 'Worker'

View File

@ -54,7 +54,7 @@ class ElasticsearchConnection(BaseConnection):
"end_time": {"type": "date", "format": "epoch_second"},
"voting": {"type": "boolean"},
"log_url": {"type": "keyword"},
"node_name": {"type": "keyword"}
"nodeset": {"type": "keyword"}
}
def __init__(self, driver, connection_name, connection_config):

View File

@ -0,0 +1,38 @@
# 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.
"""build_nodeset
Revision ID: 40c49b6fc2e3
Revises: 52d49e1bfe22
Create Date: 2021-06-26 11:16:47.714999
"""
# revision identifiers, used by Alembic.
revision = '40c49b6fc2e3'
down_revision = '52d49e1bfe22'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def upgrade(table_prefix=''):
op.drop_column(table_prefix + 'zuul_build', 'node_name')
op.add_column(
table_prefix + 'zuul_build', sa.Column('nodeset', sa.String(255)))
def downgrade():
raise Exception("Downgrades not supported")

View File

@ -60,7 +60,7 @@ class DatabaseSession(object):
def getBuilds(self, tenant=None, project=None, pipeline=None,
change=None, branch=None, patchset=None, ref=None,
newrev=None, event_id=None, uuid=None, job_name=None,
voting=None, node_name=None, result=None, provides=None,
voting=None, nodeset=None, result=None, provides=None,
final=None, held=None, limit=50, offset=0):
build_table = self.connection.zuul_build_table
@ -101,7 +101,7 @@ class DatabaseSession(object):
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)
q = self.listFilter(q, build_table.c.node_name, node_name)
q = self.listFilter(q, build_table.c.nodeset, nodeset)
q = self.listFilter(q, build_table.c.result, result)
q = self.listFilter(q, build_table.c.final, final)
q = self.listFilter(q, provides_table.c.name, provides)
@ -333,10 +333,10 @@ class SQLConnection(BaseConnection):
end_time = sa.Column(sa.DateTime)
voting = sa.Column(sa.Boolean)
log_url = sa.Column(sa.String(255))
node_name = sa.Column(sa.String(255))
error_detail = sa.Column(sa.TEXT())
final = sa.Column(sa.Boolean)
held = sa.Column(sa.Boolean)
nodeset = sa.Column(sa.String(255))
buildset = orm.relationship(BuildSetModel, backref="builds")
sa.Index(self.table_prefix + 'job_name_buildset_id_idx',

View File

@ -55,7 +55,7 @@ class SQLReporter(BaseReporter):
end_time=end,
voting=build.job.voting,
log_url=log_url,
node_name=build.node_name,
nodeset=build.job.nodeset.name,
error_detail=build.error_detail,
final=final,
held=build.held,
@ -118,7 +118,7 @@ class SQLReporter(BaseReporter):
job_name=build.job.name,
start_time=start,
voting=build.job.voting,
node_name=build.node_name,
nodeset=build.job.nodeset.name,
)
return db_build
@ -136,7 +136,6 @@ class SQLReporter(BaseReporter):
db_build.result = build.result
db_build.end_time = end
db_build.log_url = build.log_url
db_build.node_name = build.node_name
db_build.error_detail = build.error_detail
db_build.final = final
db_build.held = build.held

View File

@ -2166,8 +2166,6 @@ class Build(object):
self.held = False
self.parameters = {}
self.worker = Worker()
self.node_labels = []
self.node_name = None
self.zuul_event_id = zuul_event_id
self.build_request_ref = None
@ -3327,8 +3325,6 @@ class QueueItem(object):
'retry': build.retry if build else None,
'tries': self.current_build_set.getTries(job.name),
'queued': job.queued,
'node_labels': build.node_labels if build else [],
'node_name': build.node_name if build else None,
'worker': worker,
'waiting_status': waiting_status,
})

View File

@ -1746,8 +1746,6 @@ class Scheduler(threading.Thread):
)
event_result = event.result
build.node_labels = event_result.get("node_labels", [])
build.node_name = event_result.get("node_name")
result = event_result.get("result")
build.error_detail = event_result.get("error_detail")

View File

@ -935,7 +935,7 @@ class ZuulWebAPI(object):
'duration': duration,
'voting': build.voting,
'log_url': build.log_url,
'node_name': build.node_name,
'nodeset': build.nodeset,
'error_detail': build.error_detail,
'final': build.final,
'artifacts': [],
@ -980,7 +980,7 @@ class ZuulWebAPI(object):
@cherrypy.tools.json_out(content_type='application/json; charset=utf-8')
def builds(self, tenant, project=None, pipeline=None, change=None,
branch=None, patchset=None, ref=None, newrev=None,
uuid=None, job_name=None, voting=None, node_name=None,
uuid=None, job_name=None, voting=None, nodeset=None,
result=None, final=None, held=None, limit=50, skip=0):
connection = self._get_connection()
@ -994,7 +994,7 @@ class ZuulWebAPI(object):
builds = connection.getBuilds(
tenant=tenant, project=project, pipeline=pipeline, change=change,
branch=branch, patchset=patchset, ref=ref, newrev=newrev,
uuid=uuid, job_name=job_name, voting=voting, node_name=node_name,
uuid=uuid, job_name=job_name, voting=voting, nodeset=nodeset,
result=result, final=final, held=held, limit=limit, offset=skip)
resp = cherrypy.response