Fix l-c job and move to latest hacking 4.0.0

There are few failure in l-c jobs due to

- The conflict is caused by:
    The user requested pyflakes>=2.1.1
    hacking 0.12.0 depends on pyflakes==0.8.1

- The conflict is caused by:
    The user requested requests>=2.14.2
    keystonemiddleware 4.18.0 depends on requests>=2.14.2
    oslo-config 6.7.0 depends on requests>=2.18.0

Remove the flake8 and pyflake from lower constraints as they are
maintained in hacking side[1]. Maintaining in hacking aas well as
in project side can lead to version conflict. Also few more deps
from l-c as they are not used in placement directly.

Update requests version to 2.25 to fix the http connection failure with
2.18
- https://storage.bhs.cloud.ovh.net/v1/AUTH_dcaab5e32b234d56b626f72581e3644c/zuul_opendev_logs_dff/766994/6/check/openstack-tox-lower-constraints/dff1943/testr_results.html

This commits also moves the code to latest hacking 4.0.0 with W504 in
ignore list and fix W503 and other checks.

[1] 4069b0c4f5/lower-constraints.txt (L9)

Change-Id: Id2761300060597c1744e76ea77740ed380d98943
This commit is contained in:
Ghanshyam Mann 2020-12-15 10:16:51 -06:00
parent c02a073c52
commit a0acd21937
10 changed files with 62 additions and 52 deletions

View File

@ -9,12 +9,11 @@ decorator==3.4.0
extras==1.0.0 extras==1.0.0
fasteners==0.14.1 fasteners==0.14.1
fixtures==3.0.0 fixtures==3.0.0
flake8==2.5.5
future==0.16.0 future==0.16.0
gabbi==1.35.0 gabbi==1.35.0
gitdb2==2.0.3 gitdb2==2.0.3
GitPython==2.1.8 GitPython==2.1.8
hacking==0.12.0 hacking==4.0.0
iso8601==0.1.11 iso8601==0.1.11
Jinja2==2.10 Jinja2==2.10
jsonpath-rw==1.4.0 jsonpath-rw==1.4.0
@ -25,7 +24,6 @@ keystonemiddleware==4.18.0
linecache2==1.0.0 linecache2==1.0.0
Mako==1.0.7 Mako==1.0.7
MarkupSafe==1.1.1 MarkupSafe==1.1.1
mccabe==0.2.1
microversion-parse==0.2.1 microversion-parse==0.2.1
monotonic==1.4 monotonic==1.4
mox3==0.20.0 mox3==0.20.0
@ -57,7 +55,6 @@ prettytable==0.7.1
psycopg2==2.8 psycopg2==2.8
py==1.5.2 py==1.5.2
pycadf==2.7.0 pycadf==2.7.0
pyflakes==2.1.1
PyMySQL==0.8.0 PyMySQL==0.8.0
pyparsing==2.2.0 pyparsing==2.2.0
pytest==3.4.2 pytest==3.4.2
@ -69,7 +66,7 @@ python-subunit==1.2.0
pytz==2018.3 pytz==2018.3
PyYAML==3.13 PyYAML==3.13
repoze.lru==0.7 repoze.lru==0.7
requests==2.14.2 requests==2.25.0
requestsexceptions==1.4.0 requestsexceptions==1.4.0
rfc3986==0.3.1 rfc3986==0.3.1
Routes==2.3.1 Routes==2.3.1
@ -87,7 +84,6 @@ testscenarios==0.4
testtools==2.2.0 testtools==2.2.0
traceback2==1.4.0 traceback2==1.4.0
unittest2==1.1.0 unittest2==1.1.0
urllib3==1.22
WebOb==1.8.2 WebOb==1.8.2
wrapt==1.10.11 wrapt==1.10.11
wsgi-intercept==1.7.0 wsgi-intercept==1.7.0

View File

@ -34,6 +34,7 @@ def enrich_help_text(alt_db_opts):
# texts here if needed. # texts here if needed.
alt_db_opt.help = db_opt.help + alt_db_opt.help alt_db_opt.help = db_opt.help + alt_db_opt.help
# NOTE(markus_z): We cannot simply do: # NOTE(markus_z): We cannot simply do:
# conf.register_opts(oslo_db_options.database_opts, 'placement_database') # conf.register_opts(oslo_db_options.database_opts, 'placement_database')
# If we reuse a db config option for two different groups ("placement_database" # If we reuse a db config option for two different groups ("placement_database"
@ -55,48 +56,62 @@ not start.
""") """)
placement_db_opts = [ placement_db_opts = [
cfg.StrOpt('connection', cfg.StrOpt(
'connection',
help='', help='',
required=True, required=True,
secret=True), secret=True),
cfg.StrOpt('connection_parameters', cfg.StrOpt(
'connection_parameters',
default='', default='',
help=''), help=''),
cfg.BoolOpt('sqlite_synchronous', cfg.BoolOpt(
'sqlite_synchronous',
default=True, default=True,
help=''), help=''),
cfg.StrOpt('slave_connection', cfg.StrOpt(
'slave_connection',
secret=True, secret=True,
help=''), help=''),
cfg.StrOpt('mysql_sql_mode', cfg.StrOpt(
'mysql_sql_mode',
default='TRADITIONAL', default='TRADITIONAL',
help=''), help=''),
cfg.IntOpt('connection_recycle_time', cfg.IntOpt(
'connection_recycle_time',
default=3600, default=3600,
help=''), help=''),
cfg.IntOpt('max_pool_size', cfg.IntOpt(
'max_pool_size',
help=''), help=''),
cfg.IntOpt('max_retries', cfg.IntOpt(
'max_retries',
default=10, default=10,
help=''), help=''),
cfg.IntOpt('retry_interval', cfg.IntOpt(
'retry_interval',
default=10, default=10,
help=''), help=''),
cfg.IntOpt('max_overflow', cfg.IntOpt(
'max_overflow',
help=''), help=''),
cfg.IntOpt('connection_debug', cfg.IntOpt(
'connection_debug',
default=0, default=0,
help=''), help=''),
cfg.BoolOpt('connection_trace', cfg.BoolOpt(
'connection_trace',
default=False, default=False,
help=''), help=''),
cfg.IntOpt('pool_timeout', cfg.IntOpt(
'pool_timeout',
help=''), help=''),
cfg.BoolOpt('sync_on_startup', cfg.BoolOpt(
'sync_on_startup',
default=False, default=False,
help='If True, database schema migrations will be attempted when the' help='If True, database schema migrations will be attempted when the'
' web service starts.'), ' web service starts.'),
] # noqa ]
def register_opts(conf): def register_opts(conf):

View File

@ -59,7 +59,10 @@ class PlacementDirect(interceptor.RequestsInterceptor):
def __init__(self, conf, latest_microversion=False): def __init__(self, conf, latest_microversion=False):
conf.set_override('auth_strategy', 'noauth2', group='api') conf.set_override('auth_strategy', 'noauth2', group='api')
app = lambda: deploy.loadapp(conf)
def app():
return deploy.loadapp(conf)
self.url = 'http://%s/placement' % str(uuidutils.generate_uuid()) self.url = 'http://%s/placement' % str(uuidutils.generate_uuid())
# Supply our own session so the wsgi-intercept can intercept # Supply our own session so the wsgi-intercept can intercept
# the right thing. # the right thing.

View File

@ -96,8 +96,8 @@ def put_trait(req):
if want_version.matches((1, 15)): if want_version.matches((1, 15)):
# If the TraitExists exception was hit above, created_at is None # If the TraitExists exception was hit above, created_at is None
# so fall back to now for the last modified header. # so fall back to now for the last modified header.
last_modified = (trait.created_at last_modified = (trait.created_at or
or timeutils.utcnow(with_timezone=True)) timeutils.utcnow(with_timezone=True))
req.response.last_modified = last_modified req.response.last_modified = last_modified
req.response.cache_control = 'no-cache' req.response.cache_control = 'no-cache'
return req.response return req.response

View File

@ -203,8 +203,8 @@ class AllocationRequest(object):
return repr_str return repr_str
def __eq__(self, other): def __eq__(self, other):
return (set(self.resource_requests) == set(other.resource_requests) return (set(self.resource_requests) == set(other.resource_requests) and
and self.mappings == other.mappings) self.mappings == other.mappings)
def __hash__(self): def __hash__(self):
# We need a stable sort order on the resource requests to get an # We need a stable sort order on the resource requests to get an

View File

@ -36,10 +36,6 @@ class RequestLog(request_id.RequestId):
This also guards against a missing "Accept" header. This also guards against a missing "Accept" header.
""" """
format = ('%(REMOTE_ADDR)s "%(REQUEST_METHOD)s %(REQUEST_URI)s" '
'status: %(status)s len: %(bytes)s '
'microversion: %(microversion)s')
def __init__(self, application): def __init__(self, application):
self.application = application self.application = application
@ -108,13 +104,13 @@ class RequestLog(request_id.RequestId):
""" """
if size is None: if size is None:
size = '-' size = '-'
log_format = { LOG.info('%(REMOTE_ADDR)s "%(REQUEST_METHOD)s %(REQUEST_URI)s" '
'REMOTE_ADDR': environ.get('REMOTE_ADDR', '-'), 'status: %(status)s len: %(bytes)s '
'REQUEST_METHOD': environ['REQUEST_METHOD'], 'microversion: %(microversion)s',
'REQUEST_URI': req_uri, {'REMOTE_ADDR': environ.get('REMOTE_ADDR', '-'),
'status': status.split(None, 1)[0], 'REQUEST_METHOD': environ['REQUEST_METHOD'],
'bytes': size, 'REQUEST_URI': req_uri,
'microversion': environ.get( 'status': status.split(None, 1)[0],
microversion.MICROVERSION_ENVIRON, '-'), 'bytes': size,
} 'microversion': environ.get(
LOG.info(self.format, log_format) microversion.MICROVERSION_ENVIRON, '-')})

View File

@ -79,7 +79,10 @@ class PlacementFixture(fixtures.Fixture):
if self.use_intercept: if self.use_intercept:
loader = deploy.loadapp(self.conf_fixture.conf) loader = deploy.loadapp(self.conf_fixture.conf)
app = lambda: loader
def app():
return loader
self.endpoint = 'http://%s/placement' % uuidutils.generate_uuid() self.endpoint = 'http://%s/placement' % uuidutils.generate_uuid()
intercept = interceptor.RequestsInterceptor(app, url=self.endpoint) intercept = interceptor.RequestsInterceptor(app, url=self.endpoint)
intercept.install_intercept() intercept.install_intercept()

View File

@ -8,7 +8,7 @@ keystonemiddleware>=4.18.0 # Apache-2.0
Routes>=2.3.1 # MIT Routes>=2.3.1 # MIT
WebOb>=1.8.2 # MIT WebOb>=1.8.2 # MIT
jsonschema>=3.2.0 # MIT jsonschema>=3.2.0 # MIT
requests>=2.14.2 # Apache-2.0 requests>=2.25.0 # Apache-2.0
setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,>=21.0.0 # PSF/ZPL setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,>=21.0.0 # PSF/ZPL
oslo.concurrency>=3.26.0 # Apache-2.0 oslo.concurrency>=3.26.0 # Apache-2.0
oslo.config>=6.7.0 # Apache-2.0 oslo.config>=6.7.0 # Apache-2.0

View File

@ -2,11 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 hacking>=4.0.0,<4.1.0 # Apache-2.0
# remove this pyflakes from here once you bump the
# hacking to 3.2.0 or above. hacking 3.2.0 takes
# care of pyflakes version compatibilty.
pyflakes>=2.1.1
coverage!=4.4,>=4.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD

11
tox.ini
View File

@ -155,12 +155,13 @@ commands = bandit -r placement -x tests -n 5 -ll
enable-extensions = H106,H203,H904 enable-extensions = H106,H203,H904
# H405 is a good guideline, but sometimes multiline doc strings just don't have # H405 is a good guideline, but sometimes multiline doc strings just don't have
# a natural summary line. Rejecting code for this reason is wrong. # a natural summary line. Rejecting code for this reason is wrong.
ignore = H405 # W504 skipped since you must choose either W503 or W504 (they conflict)
ignore = H405, W504
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,releasenotes exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,releasenotes
# To get a list of functions that have a complexity of 17 or more, set # To get a list of functions that have a complexity of 19 or more, set
# max-complexity to 17 and run 'tox -epep8'. # max-complexity to 19 and run 'tox -epep8'.
# 16 is currently the most complex thing we have # 19 is currently the most complex thing we have
max-complexity=17 max-complexity=19
[testenv:bindep] [testenv:bindep]
# Do not install any requirements. We want this to be fast and work even if # Do not install any requirements. We want this to be fast and work even if