glance-manage --version is broken

Bug #1085984 reported by Mark McLoughlin
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Low
Brian Waldon
Grizzly
Fix Released
Low
Brian Waldon
oslo-incubator
Fix Released
Medium
Davanum Srinivas (DIMS)
Grizzly
Fix Released
Medium
Davanum Srinivas (DIMS)

Bug Description

With glance grizzly-1-35-g8b0b9f3, I'm seeing this:

 $ glance-manage --version
 Traceback (most recent call last):
  File "/usr/bin/glance-manage", line 7, in <module>
    execfile(__file__)
    ..
  File "/usr/lib64/python2.7/optparse.py", line 1565, in expand_prog_name
    return s.replace("%prog", self.get_prog_name())
 AttributeError: '_deferred_version_string' object has no attribute 'replace'

The issue is with our _deferred_version_string helper class which tries to defer actually creating a version string until later.

Mark McLoughlin (markmc)
Changed in oslo:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

Mark,

this seems to work, is that the right solution though?

dims@dims-desktop:/opt/stack/glance$ git diff
diff --git a/glance/openstack/common/version.py b/glance/openstack/common/version.py
index a19e422..eb47a3e 100644
--- a/glance/openstack/common/version.py
+++ b/glance/openstack/common/version.py
@@ -36,6 +36,9 @@ class _deferred_version_string(object):
     def __repr__(self):
         return "%s%s" % (self.prefix, self.version_info.version_string())

+ def replace(self, old, new):
+ return self.__str__().replace(old, new)
+

 class VersionInfo(object):

Revision history for this message
Mark McLoughlin (markmc) wrote :

It's worth a try, certainly looks good to me

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

Hmmm. oslo show a different error "TypeError: argument of type '_deferred_version_string' is not iterable"

http://paste.openstack.org/show/27310/

with this test patch

http://paste.openstack.org/show/27311/

If i add a __iter__ then it fails, with another problem

    help = self._root_section.format_help()
  File "/usr/lib/python2.7/argparse.py", line 209, in format_help
    func(*args)
  File "/usr/lib/python2.7/argparse.py", line 483, in _format_text
    return self._fill_text(text, text_width, indent) + '\n\n'
  File "/usr/lib/python2.7/argparse.py", line 619, in _fill_text
    text = self._whitespace_matcher.sub(' ', text).strip()
TypeError: expected string or buffer

will keep looking

Revision history for this message
Mark McLoughlin (markmc) wrote :

Fix proposed to oslo-incubator: https://review.openstack.org/17439

Changed in oslo:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo-incubator (master)

Reviewed: https://review.openstack.org/17439
Committed: http://github.com/openstack/oslo-incubator/commit/c67f2881a4bbe5958048610458180c3f9d914964
Submitter: Jenkins
Branch: master

commit c67f2881a4bbe5958048610458180c3f9d914964
Author: Davanum Srinivas <email address hidden>
Date: Mon Dec 3 23:51:18 2012 -0500

    Fix broken --version command

    The code for lazy loading of version string was broken. The way it
    breaks in glance and oslo is different. This patch is just for oslo.
    Here we end up overriding more methods in our lazy string class to make
    argparse happy and added test cases to make sure we don't break again.
    we also sure we cache the result of the lookup so we return the same
    version everytime and for performance. Added a few test cases as well.

    Fixes LP #1085984

    Change-Id: I0635899c37fa8e5a7edf282907d2a5e04aa064cb

Changed in oslo:
status: In Progress → Fix Committed
Brian Waldon (bcwaldon)
Changed in glance:
status: New → In Progress
assignee: nobody → Brian Waldon (bcwaldon)
milestone: none → grizzly-2
Thierry Carrez (ttx)
Changed in oslo:
milestone: none → grizzly-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: grizzly-2 → grizzly-3
Mark McLoughlin (markmc)
Changed in oslo:
assignee: nobody → Davanum Srinivas (DIMS) (dims-v)
Revision history for this message
Brian Waldon (bcwaldon) wrote :

This appears to be fixed in Glance, now:

$ glance-manage --version
2013.1

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in glance:
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.