Module import errors on check_swift_storage.py

Bug #1822334 reported by Tiago Pasqualini da Silva
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Swift Storage Charm
Fix Released
High
Tiago Pasqualini da Silva

Bug Description

Commit I98f4e6664080407a045ca5e76db59d46ffa9c38a changed this charm runtime to python 3 and some packages/modules changed. One file in particular has an issue, where the package is being imported, but not the submodules inside it, causing it to fail with the stacktrace below:

$ ./check_swift_storage.py -m -r 60 180 10 20
Traceback (most recent call last):
  File "./check_swift_storage.py", line 100, in check_replication
    data = urllib.request.urlopen(url).read().decode('utf-8')
AttributeError: module 'urllib' has no attribute 'request'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./check_swift_storage.py", line 167, in <module>
    results.extend(check_replication(base_url, args.check_replication))
  File "./check_swift_storage.py", line 102, in check_replication
    except urllib.error.URLError:
AttributeError: module 'urllib' has no attribute 'error'

This can be easily fixed by explicitly importing the modules inside the package.

Tags: sts
tags: added: sts
Revision history for this message
Tiago Pasqualini da Silva (tiago.pasqualini) wrote :
Changed in charm-swift-storage:
assignee: nobody → Tiago Pasqualini da Silva (tiago.pasqualini)
status: New → In Progress
Changed in charm-swift-storage:
milestone: none → 19.04
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-swift-storage (master)

Reviewed: https://review.openstack.org/648703
Committed: https://git.openstack.org/cgit/openstack/charm-swift-storage/commit/?id=dc63810cb4ea1c163197e1ae96c20aa03b9fee1f
Submitter: Zuul
Branch: master

commit dc63810cb4ea1c163197e1ae96c20aa03b9fee1f
Author: tpsilva <email address hidden>
Date: Fri Mar 29 11:30:29 2019 -0300

    Fix import errors on Nagios check file

    After changing the charm runtime to Python 3, some imports are failing
    on check_swift_storage.py. This can be fixed by explicitly imporgin the
    modules inside the package, instead of just importing the package.

    Change-Id: I746071042b669a1725744d4e32ea733eb40b309a
    Closes-bug: #1822334

Changed in charm-swift-storage:
status: In Progress → Fix Committed
David Ames (thedac)
Changed in charm-swift-storage:
status: Fix Committed → Fix Released
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.