AttributeError: 'ContentBad' object has no attribute 'message'

Bug #1669049 reported by Francis Ginther
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-repository-cache (Juju Charms Collection)
Fix Released
Undecided
Unassigned

Bug Description

This Traceback is being seen with the is-mojo-ci testing [1]:

2017-02-25 12:38:05 INFO juju-log Starting repository mirror verification.
2017-02-25 12:38:05 INFO juju-log Verifying distribution zesty-updates
2017-02-25 12:38:06 INFO juju-log Verifying distribution zesty-security
2017-02-25 12:38:07 INFO juju-log Verifying distribution zesty-proposed
2017-02-25 12:38:31 INFO juju-log Verifying distribution zesty-backports
2017-02-25 12:38:32 INFO juju-log Verifying distribution zesty
2017-02-25 12:38:38 INFO start Traceback (most recent call last):
2017-02-25 12:38:38 INFO start File "/var/lib/juju/agents/unit-ubuntu-repository-cache-0/charm/lib/ubuntu_repository_cache/metadata_sync.py", line 195, in mirror_archive
2017-02-25 12:38:38 INFO start _verify_repository(dest, log)
2017-02-25 12:38:38 INFO start File "/var/lib/juju/agents/unit-ubuntu-repository-cache-0/charm/lib/ubuntu_repository_cache/metadata_sync.py", line 428, in _verify_repository
2017-02-25 12:38:38 INFO start _verify_distribution(dist_dir, release)
2017-02-25 12:38:38 INFO start File "/var/lib/juju/agents/unit-ubuntu-repository-cache-0/charm/lib/ubuntu_repository_cache/metadata_sync.py", line 487, in _verify_distribution
2017-02-25 12:38:38 INFO start raise ContentBad(msg)
2017-02-25 12:38:38 INFO start ubuntu_repository_cache.metadata_sync.ContentBad: Sizes do not match for universe/dep11/Components-amd64.yml.xz in zesty
2017-02-25 12:38:38 INFO start
2017-02-25 12:38:38 INFO start During handling of the above exception, another exception occurred:
2017-02-25 12:38:38 INFO start
2017-02-25 12:38:38 INFO start Traceback (most recent call last):
2017-02-25 12:38:38 INFO start File "/var/lib/juju/agents/unit-ubuntu-repository-cache-0/charm/hooks/start", line 245, in <module>
2017-02-25 12:38:38 INFO start HOOKS.execute(sys.argv)
2017-02-25 12:38:38 INFO start File "/var/lib/juju/agents/unit-ubuntu-repository-cache-0/charm/lib/charmhelpers/core/hookenv.py", line 715, in execute
2017-02-25 12:38:38 INFO start self._hooks[hook_name]()
2017-02-25 12:38:38 INFO start File "/var/lib/juju/agents/unit-ubuntu-repository-cache-0/charm/hooks/start", line 137, in start
2017-02-25 12:38:38 INFO start LOG)
2017-02-25 12:38:38 INFO start File "/var/lib/juju/agents/unit-ubuntu-repository-cache-0/charm/lib/ubuntu_repository_cache/metadata_sync.py", line 197, in mirror_archive
2017-02-25 12:38:38 INFO start log('Verification failed: %s' % excp.message)
2017-02-25 12:38:38 INFO start AttributeError: 'ContentBad' object has no attribute 'message'
2017-02-25 12:38:39 ERROR juju.worker.uniter.operation runhook.go:107 hook "start" failed: exit status 1

The problem is due to trying to reference the 'message' attribute. The Exception base class 'message' attribute existed in python2, but does not in python3. And this code is being run with python3. This can be demonstrated by:

fginther@blackened:/tmp/scratch$ cat content-bad.py

class ContentBad(Exception):
    '''Mirror content is inconsistent'''
    pass

try:
    print('Entering')
    raise ContentBad('It\'s very bad, the absolute worse')
    print('Exiting')
except ContentBad as excp:
    print('Content bad: {}'.format(excp.message))

fginther@blackened:/tmp/scratch$ python content-bad.py
Entering
Content bad: It's very bad, the absolute worse
fginther@blackened:/tmp/scratch$ python3 content-bad.py
Entering
Traceback (most recent call last):
  File "content-bad.py", line 9, in <module>
    raise ContentBad('It\'s very bad, the absolute worse')
__main__.ContentBad: It's very bad, the absolute worse

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "content-bad.py", line 12, in <module>
    print('Content bad: {}'.format(excp.message))
AttributeError: 'ContentBad' object has no attribute 'message'

The fix is to just drop the '.message' from the format 'excp'. I'll have an MP up shortly.

[1] https://jenkins.canonical.com/is-mojo-ci/job/live-cdo-archive-mirror-aws/117/console

Chris Glass (tribaal)
Changed in ubuntu-repository-cache (Juju Charms Collection):
status: New → Fix Committed
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.