'jsonschema' has no attribute 'compat'

Bug #1946321 reported by Martin Kopec
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tempest
Fix Released
High
Martin Kopec

Bug Description

 venv run-test: commands[0] | tempest verify-config -uro /tmp/tmp.ycOSrIfXhB
 /opt/stack/tempest/tempest/lib/services/clients.py:211: DeprecationWarning: Class 'tempest.lib.services.volume.v2.extensions_client.ExtensionsClient' has moved to 'tempest.lib.services.volume.v3.extensions_client.ExtensionsClient' in version 'Rocky' and will be removed in a future version
   _client = klass(auth_provider=auth_provider, **kwargs)
 Traceback (most recent call last):
   File "/opt/stack/tempest/tempest/cmd/verify_tempest_config.py", line 490, in take_action
     main(parsed_args)
   File "/opt/stack/tempest/tempest/cmd/verify_tempest_config.py", line 462, in main
     results = verify_extensions(os, service, results)
   File "/opt/stack/tempest/tempest/cmd/verify_tempest_config.py", line 262, in verify_extensions
     resp = extensions_client.list_extensions()
   File "/opt/stack/tempest/tempest/lib/services/compute/extensions_client.py", line 29, in list_extensions
     self.validate_response(schema.list_extensions, resp, body)
   File "/opt/stack/tempest/tempest/lib/common/rest_client.py", line 976, in validate_response
     format_checker=FORMAT_CHECKER)
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/validators.py", line 965, in validate
     error = exceptions.best_match(validator.iter_errors(instance))
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/exceptions.py", line 354, in best_match
     best = next(errors, None)
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/validators.py", line 224, in iter_errors
     for error in errors:
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/_validators.py", line 333, in properties
     schema_path=property,
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/validators.py", line 240, in descend
     for error in self.evolve(schema=schema).iter_errors(instance):
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/validators.py", line 224, in iter_errors
     for error in errors:
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/_legacy_validators.py", line 94, in items_draft3_draft4
     yield from validator.descend(item, items, path=index)
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/validators.py", line 240, in descend
     for error in self.evolve(schema=schema).iter_errors(instance):
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/validators.py", line 224, in iter_errors
     for error in errors:
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/_validators.py", line 333, in properties
     schema_path=property,
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/validators.py", line 240, in descend
     for error in self.evolve(schema=schema).iter_errors(instance):
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/validators.py", line 224, in iter_errors
     for error in errors:
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/_validators.py", line 238, in format
     validator.format_checker.check(instance, format)
   File "/opt/stack/tempest/.tox/venv/lib/python3.6/site-packages/jsonschema/_format.py", line 97, in check
     result = func(instance)
   File "/opt/stack/tempest/tempest/lib/common/jsonschema_validator.py", line 35, in _validate_datetime_format
     if isinstance(instance, jsonschema.compat.str_types):
 AttributeError: module 'jsonschema' has no attribute 'compat'

Tempest uses a non public interface (compat.py):
https://github.com/Julian/jsonschema/blob/v3.2.0/jsonschema/compat.py
which got removed and therefore it's failing.

In the year when it was added - https://opendev.org/openstack/tempest/commit/f9ded3536646bb3998325f3417ef4ed588e05b7d
the interface wasn't marked as non public back then - that got changed in 2018 - https://github.com/Julian/jsonschema/commit/3c9b61c4ef302cf3463f8d82b7976be7e3400147#diff-0b60cfc7f89b490c3e18c14d830f4619c1f75ae9876b92cae8065b9c8a8004f5

It seems that the compat.py module was just for py2/3 compatibility.

Changed in tempest:
status: New → In Progress
Martin Kopec (mkopec)
Changed in tempest:
assignee: nobody → Martin Kopec (mkopec)
importance: Undecided → High
Revision history for this message
Bernard Cafarelli (bcafarel) wrote :

This matches what I see in recent tempest job failures in neutron stable/stein:
https://zuul.opendev.org/t/openstack/build/5b5c49d55c4740d9af2bc64e72927fdc
And similarly in grenade in stable/train:
https://zuul.opendev.org/t/openstack/build/4badace1f2bd47449eb2b09b5bfe53db

Interestingly, newer branches (and especially master) recent patches do not seem to have the issue, validator not being called?

Revision history for this message
Martin Kopec (mkopec) wrote :

it's not that the validator is not being called, if the issue is not happening it means that the newest (>3.2.0) jsonschema wasn't installed.

master tempest will be fixed by this: https://review.opendev.org/c/openstack/tempest/+/812804

Revision history for this message
Bernard Cafarelli (bcafarel) wrote :

Ack, the issue is not visible on neutron anymore (grenade jobs passed on train), we now have another issue on train https://bugs.launchpad.net/neutron/+bug/1946748 but probably unrelated

Revision history for this message
Martin Kopec (mkopec) wrote :
Revision history for this message
Ghanshyam Mann (ghanshyammann) wrote :

This is fixed by https://review.opendev.org/c/openstack/devstack/+/812092

basically we need to use last compatible version of old tempest in stable branch where any deps shows the incompatibly.

Revision history for this message
Ghanshyam Mann (ghanshyammann) wrote :
Revision history for this message
Martin Kopec (mkopec) wrote :

Discussed today during our office hour:

https://meetings.opendev.org/meetings/qa/2021/qa.2021-10-12-14.00.log.html#l-114

14:35:27 <kopecmartin> #link https://bugs.launchpad.net/tempest/+bug/1946321
14:35:34 <kopecmartin> 'jsonschema' has no attribute 'compat'
14:35:45 <kopecmartin> we have a fix for master
14:35:46 <kopecmartin> #link https://review.opendev.org/c/openstack/tempest/+/812804
14:36:09 <kopecmartin> what will we do with older releases? we can't modify tempest there :/
14:36:34 <gmann> that is fixed by this #link https://review.opendev.org/c/openstack/devstack/+/812092
14:36:58 <gmann> we need to use the latest compatible version on stable branches where we use old tempest
14:37:53 <kopecmartin> that makes sense
14:38:17 <kopecmartin> ok then, gmann please review this when you have a moment
14:38:18 <gmann> we have a set of compatible tempest version for any stable branch so using any version from that range works
14:38:18 <kopecmartin> #link https://review.opendev.org/c/openstack/tempest/+/812804
14:38:47 <gmann> ah sure, i thought I did :) will re-review
14:38:54 <kopecmartin> thanks

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tempest (master)

Reviewed: https://review.opendev.org/c/openstack/tempest/+/812804
Committed: https://opendev.org/openstack/tempest/commit/a47c8afc0eb3b14a7482b884fc75dd701712bc1b
Submitter: "Zuul (22348)"
Branch: master

commit a47c8afc0eb3b14a7482b884fc75dd701712bc1b
Author: Martin Kopec <email address hidden>
Date: Thu Oct 7 09:15:55 2021 +0200

    Get rid of jsonschema.compat usage

    jsonschema.compat module is not a public interface anymore and
    it got removed in version > 3.2.0
    The compat module was a helper for py2/3 compatibility [1].
    As Tempest is full py3 now, we can rework the whole
    if-condition and let the timeutils to handle any wrong format.

    [1] https://github.com/Julian/jsonschema/blob/v3.2.0/jsonschema/compat.py

    Closes-Bug: #1946321
    Change-Id: Ia78c19c06cfb712b1b8d0aff457fd2f91144dc07

Changed in tempest:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tempest 29.1.0

This issue was fixed in the openstack/tempest 29.1.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.