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
changes/94/766994/9
Ghanshyam Mann 2 years ago
parent c02a073c52
commit a0acd21937
  1. 8
      lower-constraints.txt
  2. 45
      placement/conf/database.py
  3. 5
      placement/direct.py
  4. 4
      placement/handlers/trait.py
  5. 4
      placement/objects/allocation_candidate.py
  6. 24
      placement/requestlog.py
  7. 5
      placement/tests/functional/fixtures/placement.py
  8. 2
      requirements.txt
  9. 6
      test-requirements.txt
  10. 11
      tox.ini

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

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

@ -59,7 +59,10 @@ class PlacementDirect(interceptor.RequestsInterceptor):
def __init__(self, conf, latest_microversion=False):
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())
# Supply our own session so the wsgi-intercept can intercept
# the right thing.

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

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

@ -36,10 +36,6 @@ class RequestLog(request_id.RequestId):
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):
self.application = application
@ -108,13 +104,13 @@ class RequestLog(request_id.RequestId):
"""
if size is None:
size = '-'
log_format = {
'REMOTE_ADDR': environ.get('REMOTE_ADDR', '-'),
'REQUEST_METHOD': environ['REQUEST_METHOD'],
'REQUEST_URI': req_uri,
'status': status.split(None, 1)[0],
'bytes': size,
'microversion': environ.get(
microversion.MICROVERSION_ENVIRON, '-'),
}
LOG.info(self.format, log_format)
LOG.info('%(REMOTE_ADDR)s "%(REQUEST_METHOD)s %(REQUEST_URI)s" '
'status: %(status)s len: %(bytes)s '
'microversion: %(microversion)s',
{'REMOTE_ADDR': environ.get('REMOTE_ADDR', '-'),
'REQUEST_METHOD': environ['REQUEST_METHOD'],
'REQUEST_URI': req_uri,
'status': status.split(None, 1)[0],
'bytes': size,
'microversion': environ.get(
microversion.MICROVERSION_ENVIRON, '-')})

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

@ -8,7 +8,7 @@ keystonemiddleware>=4.18.0 # Apache-2.0
Routes>=2.3.1 # MIT
WebOb>=1.8.2 # 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
oslo.concurrency>=3.26.0 # Apache-2.0
oslo.config>=6.7.0 # Apache-2.0

@ -2,11 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking!=0.13.0,<0.14,>=0.12.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
hacking>=4.0.0,<4.1.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD

@ -155,12 +155,13 @@ commands = bandit -r placement -x tests -n 5 -ll
enable-extensions = H106,H203,H904
# 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.
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
# To get a list of functions that have a complexity of 17 or more, set
# max-complexity to 17 and run 'tox -epep8'.
# 16 is currently the most complex thing we have
max-complexity=17
# To get a list of functions that have a complexity of 19 or more, set
# max-complexity to 19 and run 'tox -epep8'.
# 19 is currently the most complex thing we have
max-complexity=19
[testenv:bindep]
# Do not install any requirements. We want this to be fast and work even if

Loading…
Cancel
Save