cannot reference version info when referencing openstack sdk

Bug #1588823 reported by Qiming Teng
44
This bug affects 9 people
Affects Status Importance Assigned to Milestone
OpenStack SDK
Confirmed
Undecided
Sachin

Bug Description

There are cases where openstacksdk version info cannot be referenced.

Example 1:

[tengqm@node1 sdk]$ git checkout master
Switched to branch 'master'
[tengqm@node1 sdk]$ cd
[tengqm@node1 ~]$ cd /opt/stack/senlin
[tengqm@node1 senlin]$ reno new test
Traceback (most recent call last):
  File "/usr/bin/reno", line 7, in <module>
    from reno.main import main
  File "/usr/lib/python2.7/site-packages/reno/__init__.py", line 15, in <module>
    import pbr.version
  File "/usr/lib/python2.7/site-packages/pbr/version.py", line 25, in <module>
    import pkg_resources
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2927, in <module>
    @_call_aside
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2913, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 956, in subscribe
    callback(dist)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2952, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2515, in activate
    declare_namespace(pkg)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2097, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2046, in _handle_ns
    loader.load_module(packageName)
  File "/usr/lib64/python2.7/pkgutil.py", line 246, in load_module
    mod = imp.load_module(fullname, self.file, self.filename, self.etc)
  File "/opt/stack/sdk/openstack/__init__.py", line 18, in <module>
    __version__ = pbr.version.VersionInfo('openstacksdk').version_string()
AttributeError: 'module' object has no attribute 'version'

Example 2:

[tengqm@node1 devstack]$ /usr/bin/senlin-engine --config-file=/etc/senlin/senlin.conf & echo $! >/opt/stack/status/stack/sl-eng.pid; fg || echo "sl-eng failed to start" | tee "/opt/stack/status/stack/sl-eng.failure"
[1] 23446
/usr/bin/senlin-engine --config-file=/etc/senlin/senlin.conf
Traceback (most recent call last):
  File "/usr/bin/senlin-engine", line 6, in <module>
    from senlin.cmd.engine import main
  File "/opt/stack/senlin/senlin/cmd/engine.py", line 18, in <module>
    from oslo_config import cfg
  File "/usr/lib/python2.7/site-packages/oslo_config/cfg.py", line 365, in <module>
    from debtcollector import removals
  File "/usr/lib/python2.7/site-packages/debtcollector/__init__.py", line 15, in <module>
    import pbr.version
  File "/usr/lib/python2.7/site-packages/pbr/version.py", line 25, in <module>
    import pkg_resources
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2927, in <module>
    @_call_aside
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2913, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 956, in subscribe
    callback(dist)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2952, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2515, in activate
    declare_namespace(pkg)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2097, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2046, in _handle_ns
    loader.load_module(packageName)
  File "/usr/lib64/python2.7/pkgutil.py", line 246, in load_module
    mod = imp.load_module(fullname, self.file, self.filename, self.etc)
  File "/opt/stack/sdk/openstack/__init__.py", line 18, in <module>
    __version__ = pbr.version.VersionInfo('openstacksdk').version_string()
AttributeError: 'module' object has no attribute 'version'

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

Reviewed: https://review.openstack.org/325088
Committed: https://git.openstack.org/cgit/openstack/python-openstacksdk/commit/?id=2f05a3d0667efa07004c71e13217f1ed6d95b198
Submitter: Jenkins
Branch: master

commit 2f05a3d0667efa07004c71e13217f1ed6d95b198
Author: tengqm <email address hidden>
Date: Fri Jun 3 03:13:15 2016 -0400

    Move version definition

    Having openstack/__init__.py referencing pbr is causing some problems
    sometimes when invoking sdk apis. This patch propose moving the version
    definition into a module under openstack/.

    Close-Bug: 1588823
    Change-Id: I587de91ea7f523bb923ed9ac665a0b46d40d722c

Revision history for this message
Sachin (sacpatil) wrote :

This issue occurred to me while deploying devstack(stable/mitaka) on Fedora-23.

~~~
Traceback (most recent call last):
  File "/usr/bin/openstack", line 7, in <module>
    from openstackclient.shell import main
  File "/usr/lib/python2.7/site-packages/openstackclient/shell.py", line 32, in <module>
    from openstackclient.common import clientmanager
  File "/usr/lib/python2.7/site-packages/openstackclient/common/clientmanager.py", line 293, in <module>
    'openstack.cli.base',
  File "/usr/lib/python2.7/site-packages/openstackclient/common/clientmanager.py", line 264, in get_plugin_modules
    __import__(ep.module_name)
  File "/usr/lib/python2.7/site-packages/openstackclient/network/client.py", line 16, in <module>
    from openstack import connection
  File "/usr/lib/python2.7/site-packages/openstack/connection.py", line 68, in <module>
    from openstack import session as _session
  File "/usr/lib/python2.7/site-packages/openstack/session.py", line 29, in <module>
    DEFAULT_USER_AGENT = "openstacksdk/%s" % openstack.__version__
AttributeError: 'module' object has no attribute '__version__'
~~~

Installed openstacksdk versions:
- openstacksdk (0.8.1)
- python-openstacksdk (0.5.2)

Changed "openstacksdk===0.9.11" in file: /opt/stack/requirements/upper-constraints.txt to solve the issue

Sachin (sacpatil)
Changed in python-openstacksdk:
assignee: nobody → Sachin (sacpatil)
Revision history for this message
Tony Breeds (o-tony) wrote :

As I said in my review on on https://review.openstack.org/#/c/415032 :

We can't do that as the versions that 0.9.1 requires are not compatible with the constraints of stable/mitaka. For example 0.9.1 requires 'stevedore>=1.16.0' BUT we only support 1.12.0 in mitaka [1]

So we need to find a way to reproduce this (as I can't) so we can find an alternate way to resolve the issue as mitaka (at least) has 6 months of life left!

[1] http://git.openstack.org/cgit/openstack/requirements/tree/upper-constraints.txt?h=stable/mitaka#n346

Revision history for this message
Deepinder Setia (dsetia) wrote :

I see this issue if I run stack.sh in stable/mitaka branch of devstack. Tony, I don't know why you aren't able to reproduce this. Would occurrence of this depend on configuration?

Revision history for this message
Goutham Pacha Ravi (gouthamr) wrote :

+1 Confirming this bug with devstack-ing stable/mitaka.

Changed in python-openstacksdk:
status: New → Confirmed
Revision history for this message
Goutham Pacha Ravi (gouthamr) wrote :
Revision history for this message
cheng liu (lchian) wrote :

+1 Confirming this bug with devstack-ing stable/mitaka.

Revision history for this message
Masayuki Igawa (igawa) wrote :

@Goutham, @cheng: I'd like to know the cause of this bug, but I don't see this failure in https://review.openstack.org/#/q/status:open+project:openstack/cinder+branch:stable/mitaka . For example,

In http://logs.openstack.org/43/405443/2/check/gate-tempest-dsvm-neutron-full-ubuntu-trusty/1d7fa19/logs/devstacklog.txt.gz , there's no "AttributeError: 'module' object has no attribute '__version__'" in this log.

So, could you share the url of the log which contains the failure?

Revision history for this message
ydemiral (yasemin-demiral) wrote :

i try to Changed "openstacksdk===0.9.11" in file: /opt/stack/requirements/upper-constraints.txt, but it gives an error ContextualVersionConflict: (stevedore 1.12.0 (/usr/local/lib/python2.7/dist-packages), Requirement.parse('stevedore>=1.17.1'), set(['openstacksdk'])).
i cant install devstack stable/mitaka.

Revision history for this message
Yu Long (crazymozart) wrote :

I have encountered the same error with devstack, branch is stable/mitaka, OS is Ubuntu 14.04.5:

stack@localhost:~/devstack$ ./stack.sh
....
....
+./stack.sh:main:1033 create_keystone_accounts
+lib/keystone:create_keystone_accounts:372 local admin_tenant
++lib/keystone:create_keystone_accounts:373 openstack project show admin -f value -c id
Traceback (most recent call last):
  File "/usr/local/bin/openstack", line 7, in <module>
    from openstackclient.shell import main
  File "/usr/local/lib/python2.7/dist-packages/openstackclient/shell.py", line 32, in <module>
    from openstackclient.common import clientmanager
  File "/usr/local/lib/python2.7/dist-packages/openstackclient/common/clientmanager.py", line 293, in <module>
    'openstack.cli.base',
  File "/usr/local/lib/python2.7/dist-packages/openstackclient/common/clientmanager.py", line 264, in get_plugin_modules
    __import__(ep.module_name)
  File "/usr/local/lib/python2.7/dist-packages/openstackclient/network/client.py", line 16, in <module>
    from openstack import connection
  File "/usr/local/lib/python2.7/dist-packages/openstack/connection.py", line 68, in <module>
    from openstack import session as _session
  File "/usr/local/lib/python2.7/dist-packages/openstack/session.py", line 29, in <module>
    DEFAULT_USER_AGENT = "openstacksdk/%s" % openstack.__version__
AttributeError: 'module' object has no attribute '__version__'
+lib/keystone:create_keystone_accounts:373 admin_tenant=
+lib/keystone:create_keystone_accounts:1 exit_trap

Revision history for this message
Sachin (sacpatil) wrote :

@igawa: This is strange.

@crazymozart, dsetia, gouthamr: Guys are you able to get past the issue by changing openstacksdk version?

@yasemin-demiral: We need confirmation from others too as it worked for me. I see @o-tony mentioned 'stevedore' version conflict in his comment and that is exactly what you are facing.

Revision history for this message
Szymon Borkowski (szymon-borkowski) wrote :

I think I can also confirm, I tried to stack.sh a devstack with Ironic.
Logs: http://paste.openstack.org/show/594410/

Revision history for this message
Deepinder Setia (dsetia) wrote :

@sachin, I can get past the issue by manually applying the workaround (install openstacksdk 0.9.11 and changing /opt/stack/requirements/upper-constraints.txt).

However, I clone devstack and install it nightly using a script so manual workaround isn't an option. What is the long-term solution?

Thanks

Revision history for this message
Masayuki Igawa (igawa) wrote :

I think it's good to reproduce this in the upstream gate or find a root cause of this issue. Otherwise, if we find a way to resolve/workaround this, we can't confirm it in the gate. I think it would make openstack unstable..

description: updated
Revision history for this message
Sulaco (fco-sendra) wrote :

As a quick workaround, if you change the value of DEFAULT_USER_AGENT to "openstacksdk/%s" % openstack (without .__version__) in the file /usr/local/lib/python2.7/dist-packages/openstack/session.py the installation continues properly but I'm not sure how it can affect to the whole installation.

Revision history for this message
Dolph Mathews (dolph) wrote :

I'm running into this when running the stable/newton branch of openstack-dev/grenade.

Revision history for this message
Dolph Mathews (dolph) wrote :

Rather, I'm getting the backtraces in comments #2 and #10.

2017-01-16 23:09:52.017 | ++functions:upload_image:343 grep ' id '
2017-01-16 23:09:52.018 | ++functions:upload_image:343 openstack --os-cloud=devstack-admin image create cirros-0.3.4-x86_64-uec-ramdisk --public --container-format ari --disk-format ari
2017-01-16 23:09:52.024 | ++functions-common:get_field:700 local data field
2017-01-16 23:09:52.030 | ++functions-common:get_field:701 read data
2017-01-16 23:09:53.252 | Traceback (most recent call last):
2017-01-16 23:09:53.252 | File "/usr/local/bin/openstack", line 7, in <module>
2017-01-16 23:09:53.252 | from openstackclient.shell import main
2017-01-16 23:09:53.252 | File "/usr/local/lib/python2.7/dist-packages/openstackclient/shell.py", line 32, in <module>
2017-01-16 23:09:53.252 | from openstackclient.common import clientmanager
2017-01-16 23:09:53.252 | File "/usr/local/lib/python2.7/dist-packages/openstackclient/common/clientmanager.py", line 293, in <module>
2017-01-16 23:09:53.252 | 'openstack.cli.base',
2017-01-16 23:09:53.252 | File "/usr/local/lib/python2.7/dist-packages/openstackclient/common/clientmanager.py", line 264, in get_plugin_modules
2017-01-16 23:09:53.252 | __import__(ep.module_name)
2017-01-16 23:09:53.252 | File "/usr/local/lib/python2.7/dist-packages/openstackclient/network/client.py", line 16, in <module>
2017-01-16 23:09:53.253 | from openstack import connection
2017-01-16 23:09:53.253 | File "/usr/local/lib/python2.7/dist-packages/openstack/connection.py", line 68, in <module>
2017-01-16 23:09:53.253 | from openstack import session as _session
2017-01-16 23:09:53.253 | File "/usr/local/lib/python2.7/dist-packages/openstack/session.py", line 29, in <module>
2017-01-16 23:09:53.253 | DEFAULT_USER_AGENT = "openstacksdk/%s" % openstack.__version__
2017-01-16 23:09:53.253 | AttributeError: 'module' object has no attribute '__version__'

Revision history for this message
Yu Long (crazymozart) wrote :

@sacpatil, i changed the openstacksdk version to 0.9.11, it seems well to me, and there's no conflic, it works well.

Revision history for this message
ydemiral (yasemin-demiral) wrote :

in ubuntu 16.04-stable/mitaka, i changed the openstacksdk version to 0.9.12, it works.

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.