project-config/zuul/openstack_functions.py
Sam Yaple b749f58627 Shorten the kolla job names
Due to the length of the job name and the tox target we run into an
uncommon limitation; the virtualenv that tox launches is nested in a
path that is too long. This leads to an error on our longest named
job which prevents tox from running properly.

This limitation is the limit for the line length of the first line
in a shell script. In this case <virtualenv>/bin/pip has a path that
exceeds that limit by a few characters. This results in a very
confusing "OSError: [Errno 2] No such file or directory" error.

See `man execve` for more info. A quote from that manpage:
'A maximum line length of 127 characters is allowed for the first line
in a #! executable shell script.'

To reproduce this locally you can just create a very long path and
then run tox in it. Example: http://paste.openstack.org/show/478559/

Change-Id: I51f8f67d9ab139f1d539fce05ce3cc4766aeedff
Depends-On: I43fba2a5ff1890d699045496c9eaee5e849f3e75
2015-11-11 19:57:48 +00:00

154 lines
5.8 KiB
Python

# Copyright 2013 OpenStack Foundation
#
# 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.
import re
def set_log_url(item, job, params):
if hasattr(item.change, 'refspec'):
path = "%s/%s/%s/%s/" % (
params['ZUUL_CHANGE'][-2:], params['ZUUL_CHANGE'],
params['ZUUL_PATCHSET'], params['ZUUL_PIPELINE'])
elif hasattr(item.change, 'ref'):
path = "%s/%s/%s/" % (
params['ZUUL_NEWREV'][:2], params['ZUUL_NEWREV'],
params['ZUUL_PIPELINE'])
else:
path = params['ZUUL_PIPELINE'] + '/'
params['BASE_LOG_PATH'] = path
params['LOG_PATH'] = path + '%s/%s/' % (job.name,
params['ZUUL_UUID'][:7])
def reusable_node(item, job, params):
if 'OFFLINE_NODE_WHEN_COMPLETE' in params:
del params['OFFLINE_NODE_WHEN_COMPLETE']
def devstack_params(item, job, params):
change = item.change
# Note we can't fallback on the default labels because
# jenkins uses 'devstack-precise || devstack-trusty'.
# This is necessary to get the gearman plugin to register
# gearman jobs with both node labels.
# Remove this when we are done doing prelimindary dib testing.
if 'icehouse-dibtest' in job.name:
params['ZUUL_NODE'] = 'devstack-precise-dib'
elif 'multinode' in job.name and 'dibtest' in job.name:
params['ZUUL_NODE'] = 'ubuntu-trusty-2-node'
elif 'dibtest' in job.name:
params['ZUUL_NODE'] = 'ubuntu-trusty'
elif ((hasattr(change, 'branch') and
change.branch == 'stable/icehouse') or
('icehouse' in job.name or
'precise' in job.name)):
params['ZUUL_NODE'] = 'devstack-precise'
elif 'centos7' in job.name:
params['ZUUL_NODE'] = 'devstack-centos7'
elif 'multinode' in job.name:
params['ZUUL_NODE'] = 'devstack-trusty-2-node'
else:
params['ZUUL_NODE'] = 'devstack-trusty'
def default_params_precise(item, job, params):
if 'trusty' in job.name:
params['ZUUL_NODE'] = 'bare-trusty'
else:
params['ZUUL_NODE'] = 'bare-precise'
def default_params_trusty(item, job, params):
change = item.change
# Note we can't fallback on the default labels because
# jenkins uses 'bare-precise || bare-trusty'.
# This is necessary to get the gearman plugin to register
# gearman jobs with both node labels.
if ((hasattr(change, 'branch') and
change.branch == 'stable/icehouse') or
('icehouse' in job.name or
'precise' in job.name)):
params['ZUUL_NODE'] = 'bare-precise'
elif job.name == 'bindep-nova-python27':
params['ZUUL_NODE'] = 'ubuntu-trusty'
else:
params['ZUUL_NODE'] = 'bare-trusty'
def set_node_options(item, job, params, default):
# Set up log url parameter for all jobs
set_log_url(item, job, params)
# Default to single use node. Potentially overriden below.
# Select node to run job on.
params['OFFLINE_NODE_WHEN_COMPLETE'] = '1'
proposal_re = r'^.*(merge-release-tags|(propose|upstream)-(.*?)-(constraints-.*|updates?|update-liberty))$' # noqa
release_re = r'^.*-(forge|jenkinsci|mavencentral|pypi-(both|wheel)|npm)-upload$'
hook_re = r'^hook-(.*?)-(rtfd)$'
python26_re = r'^.*-(py(thon)?)?26.*$'
centos6_re = r'^.*-centos6.*$'
fedora_re = r'^.*-f(edora-)?2(1|2).*$'
tripleo_re = r'^.*-tripleo-ci.*$'
kolla_image_re = r'^.*-kolla-dsvm-(build|deploy)-.*$'
openstack_ansible_re = r'^.*-openstack-ansible-.*$'
devstack_re = r'^.*-dsvm.*$'
puppetunit_re = (
r'^gate-(puppet-.*|system-config)-puppet-(lint|syntax|unit).*$')
# jobs run on the proposal worker
if (re.match(proposal_re, job.name) or re.match(release_re, job.name) or
re.match(hook_re, job.name)):
reusable_node(item, job, params)
# Jobs needing python26
elif re.match(python26_re, job.name):
# Pass because job specified label is always correct.
pass
# Kolla build image jobs always have the correct node label.
# Put before distro specific overrides as they list distros in
# the jobs names unrelated to where job should run.
elif re.match(kolla_image_re, job.name):
pass
# Jobs needing centos6
elif re.match(centos6_re, job.name):
# Pass because job specified label is always correct.
pass
# Jobs needing fedora 2[1|2]
elif re.match(fedora_re, job.name):
# Pass because job specified label is always correct.
pass
# Jobs needing tripleo slaves
elif re.match(tripleo_re, job.name):
# Pass because job specified label is always correct.
pass
# openstack-ansible jobs
elif re.match(openstack_ansible_re, job.name):
# Pass because job specified label is always correct.
pass
# Puppet-OpenStack jobs
elif re.match(puppetunit_re, job.name):
pass
# Jobs needing devstack slaves
elif re.match(devstack_re, job.name):
devstack_params(item, job, params)
elif default == 'trusty':
default_params_trusty(item, job, params)
else:
default_params_precise(item, job, params)
def set_node_options_default_precise(item, job, params):
set_node_options(item, job, params, 'precise')
def set_node_options_default_trusty(item, job, params):
set_node_options(item, job, params, 'trusty')