Python keystone client `users` method get() is not working

Bug #1637530 reported by Sergii Turivnyi
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Invalid
Undecided
Unassigned
python-keystoneclient
Fix Released
Undecided
Boris Bobrov

Bug Description

Using python keystone-client to update user is working not properly.
ipdb> test_user.manager.client
<keystoneclient.httpclient._KeystoneAdapter object at 0x7f6098ed8210>
ipdb> test_user.manager.client.last_request_id
*** AttributeError: '_KeystoneAdapter' object has no attribute 'last_request_id'

Steps to reproduce:
 1. authenticate

 2. create test_user:
    name='test_user_005'
    password='test'
    <email address hidden>'

 3. update test_user
    <email address hidden>'
 4. execute test_user.get()
Expected result:
    Command is executed without any errors

Actual result:
    *** AttributeError: '_KeystoneAdapter' object has no attribute 'last_request_id'

Related bug:
    https://bugs.launchpad.net/keystone/+bug/1637484

Revision history for this message
Sergii Turivnyi (sturivnyi) wrote :
Changed in keystone:
status: New → Confirmed
Revision history for this message
Lance Bragstad (lbragstad) wrote :

Marking this as invalid against keystone server code. Is this reproducible with python-openstackclient [0]? The python-keystoneclient package has deprecated all CLI support. Instead it is consumed as a package through the openstackclient for CLI operations done through openstackclient (`openstack user show`, `openstack user create`).

[0] http://docs.openstack.org/developer/python-openstackclient/

Changed in keystone:
status: Confirmed → Invalid
Revision history for this message
Sergii Turivnyi (sturivnyi) wrote :

Yes, it's reproducible with python-openstackclient
you can download script here to reproduce the issue:
https://bugs.launchpad.net/keystone/+bug/1637484/+attachment/4768844/+files/user_update.py

Changed in python-keystoneclient:
status: New → Confirmed
Revision history for this message
Lance Bragstad (lbragstad) wrote :

Thanks Sergii,

The script used keystoneclient. Were you able to recreate with python-openstackclient? What versions/shas were you able to recreate with?

Revision history for this message
Sergii Turivnyi (sturivnyi) wrote :

The issue was found in python-keystoneclient. I feel it's not connected to the python-openstackclient. Because python-openstackclient uses API.

Revision history for this message
Andriy Kurilin (andreykurilin) wrote :

Rally team tried to port all our scenarios and all jobs to Keystone V3 and we faced the similar issue while accessing user properties after successful creation.

Logs: http://logs.openstack.org/62/395562/4/check/gate-rally-dsvm-rally/0ec1f44/console.html#_2016-11-09_16_22_14_502011

What had happened?

1) Rally tries to create a user. This action succeeded. Code of creation you can find here at L86 https://review.openstack.org/#/c/394583/13/rally/plugins/openstack/services/identity/keystone_v3.py

2) Since we tried to make unified scenarios for both keystone V2 and V3, we have compatibility layer. At this stage, Rally tries to obtain several properties from user object received from stage 1. Code you can find here at L211 - https://review.openstack.org/#/c/394583/13/rally/plugins/openstack/services/identity/keystone_v3.py

3) keystoneclient as like most openstack clients supports lazy-loading properties of object. It means that keystone returned only id of new user at stage 1 and all other properties required additional inner get request - https://github.com/openstack/python-keystoneclient/blob//c8ba2be16a7f02c21e534408cb5b9bade940e495/keystoneclient/base.py#L496-L506
And at this stage we fails...

Revision history for this message
Andriy Kurilin (andreykurilin) wrote :

Simplified code from Rally to simple keystoneclient's calls:

from keystoneauth1 import identity
from keystoneauth1 import session
username = "admin"
password = "stack"
project_name = project_name="admin"
domain_name = "Default"
auth_url = "http://192.168.0.16:5000/v3"

identity_plugin = identity.Password(auth_url=auth_url, password=password, username=username, project_name=project_name, project_domain_name=domain_name, user_domain_name=domain_name)
sess = session.Session(auth=identity_plugin)
kc = client.Client(version="3", session=sess)

domain_id = kc.domains.list(name="Default")[0].id
project_id = kc.projects.list(name=project_name)[0].id

user = kc.users.create(name="some_tmp_user_2", password="passwd", default_project=project_id, <email address hidden>", domain=domain_id, enabled=True)

user.project_id

AttributeError Traceback (most recent call last)
<ipython-input-40-b55aad0db507> in <module>()
----> 1 user.project_id

/usr/local/lib/python2.7/dist-packages/keystoneclient/base.pyc in __getattr__(self, k)
    498 # NOTE(bcwaldon): disallow lazy-loading if already loaded once
    499 if not self.is_loaded():
--> 500 self.get()
    501 return self.__getattr__(k)
    502

/usr/local/lib/python2.7/dist-packages/keystoneclient/base.pyc in get(self)
    520 self._add_details(new._info)
    521 self._add_details(
--> 522 {'x_request_id': self.manager.client.last_request_id})
    523
    524 def __eq__(self, other):

AttributeError: '_KeystoneAdapter' object has no attribute 'last_request_id'

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

Fix proposed to branch: master
Review: https://review.openstack.org/396260

Changed in python-keystoneclient:
assignee: nobody → Boris Bobrov (bbobrov)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-keystoneclient (master)

Reviewed: https://review.openstack.org/396260
Committed: https://git.openstack.org/cgit/openstack/python-keystoneclient/commit/?id=0bfd6251b674c998680ee0018fc95f47e1d26fe6
Submitter: Jenkins
Branch: master

commit 0bfd6251b674c998680ee0018fc95f47e1d26fe6
Author: Boris Bobrov <email address hidden>
Date: Thu Nov 10 17:56:30 2016 +0300

    Do not add last_request_id

    It is untested and doesn't work for a while. It also causes a failure
    when the method is used by other client or by keystoneclient itself.

    Change-Id: Icdd53936a107933e275acd43b5ebe94b8d04bc4b
    Closes-Bug: 1637530

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

This issue was fixed in the openstack/python-keystoneclient 3.7.0 release.

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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