Bug 1727976 - rhosp14/openstack-keystone:14.0-107 breaks ldap authentication - TypeError: initialize() got an unexpected keyword argument 'bytes_mode'
Summary: rhosp14/openstack-keystone:14.0-107 breaks ldap authentication - TypeError:...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-keystone
Version: 14.0 (Rocky)
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: z5
: 14.0 (Rocky)
Assignee: Nathan Kinder
QA Contact: nlevinki
URL:
Whiteboard:
: 1730132 (view as bug list)
Depends On:
Blocks: 1753487
TreeView+ depends on / blocked
 
Reported: 2019-07-08 17:16 UTC by Andreas Karis
Modified: 2023-03-24 15:02 UTC (History)
11 users (show)

Fixed In Version: openstack-keystone-14.1.1-0.20190514013954.00242bd.el7ost
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-12-20 01:13:26 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github python-ldap python-ldap issues 249 0 'None' closed ldap.initialize() unknown keyword parameter bytes_strictness 2020-11-04 15:37:52 UTC
RDO 21643 0 None None None 2019-07-30 16:21:59 UTC
RDO 21697 0 None None None 2019-08-02 10:33:57 UTC
RDO 21829 0 None None None 2019-11-04 18:20:52 UTC
Red Hat Product Errata RHBA-2019:4340 0 None None None 2019-12-20 01:13:29 UTC

Description Andreas Karis 2019-07-08 17:16:21 UTC
Problem Statement	Latest Keystone container results in error for ldap authentication.
Description	

What problem/issue/behavior are you having trouble with?  What do you expect to see?

Attempts to login using the domain linked to an ldap configuration results in the following error in the keystone log:
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi [req-9282fff0-a19f-414a-947a-2d3775c1da79 - - - - -] initialize() got an unexpected keyword argument 'bytes_mode': TypeError: initialize() got an unexpected keyword argument 'bytes_mode'
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi Traceback (most recent call last):
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/common/wsgi.py", line 148, in __call__
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     result = method(req, **params)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/auth/controllers.py", line 67, in authenticate_for_to
ken
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     self.authenticate(request, auth_info, auth_context)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/auth/controllers.py", line 236, in authenticate
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     auth_info.get_method_data(method_name))
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/auth/plugins/password.py", line 31, in authenticate
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     user_info = auth_plugins.UserAuthInfo.create(auth_payload, METHOD_NAME)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/auth/plugins/core.py", line 102, in create
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     user_auth_info._validate_and_normalize_auth_data(auth_payload)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/auth/plugins/core.py", line 189, in _validate_and_normalize_auth_data
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     auth_payload)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/auth/plugins/core.py", line 166, in _validate_and_normalize_auth_data
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     user_name, domain_ref['id'])
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/common/manager.py", line 116, in wrapped
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     __ret_val = __f(*args, **kwargs)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/core.py", line 416, in wrapper
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     return f(self, *args, **kwargs)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/core.py", line 426, in wrapper
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     return f(self, *args, **kwargs)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/dogpile/cache/region.py", line 1220, in decorate
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     should_cache_fn)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/dogpile/cache/region.py", line 825, in get_or_create
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     async_creator) as value:
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/dogpile/lock.py", line 154, in __enter__
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     return self._enter()
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/dogpile/lock.py", line 94, in _enter
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     generated = self._enter_create(createdtime)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/dogpile/lock.py", line 145, in _enter_create
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     created = self.creator()
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/dogpile/cache/region.py", line 1216, in creator
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     return fn(*arg, **kw)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/core.py", line 983, in get_user_by_name
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     ref = driver.get_user_by_name(user_name, domain_id)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/backends/ldap/core.py", line 97, in get_user_by_name
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     return self.user.filter_attributes(self.user.get_by_name(user_name))
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/backends/ldap/common.py", line 1555, in get_by_name
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     res = self.get_all(query)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/backends/ldap/core.py", line 319, in get_all
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     hints=hints)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/backends/ldap/common.py", line 1862, in get_all
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     return super(EnabledEmuMixIn, self).get_all(ldap_filter, hints)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/backends/ldap/common.py", line 1564, in get_all
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     for x in self._ldap_get_all(hints, ldap_filter)]
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/common/driver_hints.py", line 42, in wrapper
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     return f(self, hints, *args, **kwargs)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/backends/ldap/common.py", line 1512, in _ldap_get_all
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     with self.get_connection() as conn:
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/backends/ldap/common.py", line 1250, in get_connection
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     pool_conn_lifetime=pool_conn_lifetime)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/backends/ldap/common.py", line 907, in connect
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     pool_conn_lifetime=pool_conn_lifetime)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi   File "/usr/lib/python2.7/site-packages/keystone/identity/backends/ldap/common.py", line 523, in connect
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi     self.conn = ldap.initialize(url, bytes_mode=False)
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi TypeError: initialize() got an unexpected keyword argument 'bytes_mode'
2019-07-03 20:15:22.831 29 ERROR keystone.common.wsgi

Where are you experiencing the behavior?  What environment?

Overcloud deployment

When does the behavior occur? Frequently?  Repeatedly?   At certain times?

Every time you try to log in. Attempted to restart keystone container, but did not help. Reviewed configurations, no changes there.  Saw there was a new container 16 hours ago that I believe recent deploy pulled in.

What information can you provide around timeframes and the business impact?

Breaks all usage from our domain accounts until resolved. We're nearing deployment of the environment to development staff and this is preventing that from continuing.

--------------------

Going from rhosp14/openstack-keystone:14.0-107  back to rhosp14/openstack-keystone:14.0-102.1557945123

Comment 1 Andreas Karis 2019-07-08 17:19:39 UTC
Customer ran:

openstack tripleo container image prepare default \
  --output-env-file containers-prepare-parameter.yaml

to generate the containers prepare yaml, and then added the following to the end of it:

- push_destination: true
    includes:
    - openstack-keystone
    set:
      tag: 14.0-102.1557945123

That then fixed their issues.

Comment 2 John Dennis 2019-07-08 18:16:24 UTC
I can take this. I was active in the review which added this ldap change to keystone and if memory serves me correctly I discovered this exact issue and filed an upstream bug against python-ldap. My assumption is the version of python-ldap paired with keystone does not have the fix. I'll investigate and add more info when I have it.

Comment 6 John Dennis 2019-07-08 19:46:11 UTC
The upstream bug for initialize() got an unexpected keyword argument 'bytes_mode' is https://github.com/python-ldap/python-ldap/issues/249.
Upstream committed fixes the first week of January 2019.
The upstream fixes first appeared in python-ldap-3.2.0 which was released 2019-03-13.

Comment 7 John Dennis 2019-07-08 20:26:18 UTC
I need to know the version of python-ldap that was installed. Unfortunately the list of RPM's in the SOS report is empty. (Plus downloading SOS reports is painfully slow). Can you please find out what the version of python-ldap was installed.

Comment 8 Jody Shumaker 2019-07-08 20:31:47 UTC
That upstream bug is about the new parameter bytes_strictness, not bytes_mode.

I'm not installing any version of python-ldap, I'm using the docker container images provided by RedHat.  You can pull the container and inspect it yourself if you want.  https://access.redhat.com/containers/?tab=security#/registry.access.redhat.com/rhosp14/openstack-keystone/images/14.0-107

As far as I can tell, the rhosp14/openstack-keystone images only have python-ldap 2.4.15-2 which does not support bytes_mode as it was added sometime in the 5 years since 2.4.15 was released.  Keystone project updated their requirement to python-ldap>=3.0.0 about a year ago. More recently, they added use of the bytes_mode parameter. Seems like the building of the rhosp14/openstack-keystone image needs to update what version of python-ldap it pulls in.

Comment 20 John Dennis 2019-07-15 22:41:54 UTC
*** Bug 1730132 has been marked as a duplicate of this bug. ***

Comment 23 Alfredo Moralejo 2019-07-30 14:30:31 UTC
For the record, updating python-ldap to >= 3.0 requires updating pyasn1 to >= 0.3.7 and pyasn1-modules to >= 0.1.5 also coming from RHEL base repos.

Comment 24 Alfredo Moralejo 2019-07-30 16:21:27 UTC
I've proposed to update python-ldap and python-pyasn1 from versions in rhel base to required versions in RDO Rocky https://review.rdoproject.org/r/#/c/21643/

Comment 25 Alfredo Moralejo 2019-07-30 17:13:15 UTC
@jdennis note that updating python-ldap in OSP means bumping from 2.4.15 included in RHEL to 3.1.0 which potentially may break other packages in rhel using python-ldap. There may be any chance of fixing this by applying any downstream patch only for osp14 (from osp15 on, they run on rhel8 which includes a recent version of python-ldap).

Comment 26 John Dennis 2019-07-30 22:08:02 UTC
re comment #25: Why would we need to update python-ldap and other packages in RHEL7? Can't the newer versions of the required dependencies be built in another repo, let's say CloudSIG. I'm assuming all the repos are enabled during an OSP install and if the spec file specifies a minimum version that is not satisfied in RHEL but is satisfied in another repo yum will fetch it from a non-RHEL repo.

RHEL is very conservative with rebasing packages so surely the necessity of needing a more current package for OSP than RHEL supplies must have come up before as an issue.

Actually, from reading https://www.rdoproject.org/documentation/requirements/ OSP doesn't install RHEL packages, it installs CentOS packages, isn't that correct?

Bottom line, can't dependencies which are newer than what is in CentOS/RHEL be provided by a non-CentOS/RHEL repo?

Comment 27 Alfredo Moralejo 2019-07-31 07:20:49 UTC
(In reply to John Dennis from comment #26)
> re comment #25: Why would we need to update python-ldap and other packages
> in RHEL7? Can't the newer versions of the required dependencies be built in
> another repo, let's say CloudSIG. I'm assuming all the repos are enabled
> during an OSP install and if the spec file specifies a minimum version that
> is not satisfied in RHEL but is satisfied in another repo yum will fetch it
> from a non-RHEL repo.
> 

Yes, I misexplained it. We provide updates in RDO repos as you mentioned and those are pulled and installed as they are newer that in RHEL/CentOS base. The problem is that may be other packages in RHEL that use python-ldap and could be affected by this update.

> RHEL is very conservative with rebasing packages so surely the necessity of
> needing a more current package for OSP than RHEL supplies must have come up
> before as an issue.

Yes, we hit it from time to time and we always try to avoid it if possible :). Just when there is no other option we provide an updated version in our repo for a package provided in CentOS/RHEL.

> 
> Actually, from reading
> https://www.rdoproject.org/documentation/requirements/ OSP doesn't install
> RHEL packages, it installs CentOS packages, isn't that correct?
> 

Yes, but for the context of this discussion, CentOS base packages has the same versions and contents as RHEL.

> Bottom line, can't dependencies which are newer than what is in CentOS/RHEL
> be provided by a non-CentOS/RHEL repo?

Yes, but it has a certain risk so we do if there is not a better alternative (in fact we are already in the way to provide it in https://review.rdoproject.org/r/#/q/topic:update-ldap+(status:open+OR+status:merged) but i want to make sure there is not a better option. Once we provide an update in the official repos, reverting is really a problem.

Comment 28 John Dennis 2019-08-01 20:27:12 UTC
> We provide updates in RDO repos as you mentioned and those are pulled and
> installed as they are newer that in RHEL/CentOS base. The problem is that
> may be other packages in RHEL that use python-ldap and could be affected
> by this update.

It's a risk but I can't see any other solution. Fortunately even though this is
a major version upgrade according to the release notes the API changes for backward
compatibility are minor, here is what I found:

The functions `ldap.open()`, `ldap.init()`, `ldif.CreateLDIF()`
and `ldif.ParseLDIF()`, which were deprecated for over a decade,
are scheduled for removal in python-ldap 3.1.

The module `ldap.async` is renamed to `ldap.asyncsearch`, due to
`async` becoming a keyword in Python 3.7.
The old module name is deprecated, but will be available as long
as Python 3.6 is supported.

> https://review.rdoproject.org/r/#/q/topic:update-ldap+(status:open+OR+status:merged)

Thank you, I think this is the right solution and the best first step in addressing the
out of sync dependencies. At the moment we have a number of dependencies that need
updating with respect to Keystone and we'll need to revisit this, but for now this
is a good first step (I am going to review what was changed in ldappool just to make
sure that doesn't have to update in lockstep with python-ldap.

Comment 29 John Dennis 2019-08-01 21:18:02 UTC
OSP14 has python-ldappool-2.3.1 which should be OK from a dependency point of view. However we've fixed bugs in ldappool that first appear in 2.4.0, I see OSP15 has 2.4.0, the OSP14 customers would probably appreciate rebasing to 2.4.0.

Comment 30 Alfredo Moralejo 2019-08-02 07:52:14 UTC
For the record, existing pysnmp-4.3.2 does not work fine with pyasn1-0.3.7 (required for python-ldap), we need to update it to pysnmp>4.3.9 (will rebase to 4.4.X which is in u-c), see https://review.rdoproject.org/r/#/c/21681/

Comment 31 Alfredo Moralejo 2019-08-02 09:20:33 UTC
(In reply to John Dennis from comment #29)
> OSP14 has python-ldappool-2.3.1 which should be OK from a dependency point
> of view. However we've fixed bugs in ldappool that first appear in 2.4.0, I
> see OSP15 has 2.4.0, the OSP14 customers would probably appreciate rebasing
> to 2.4.0.

We follow the versions that are in upper-constraints.txt for each release. For ldappool in rocky it's 2.3.1:

https://github.com/openstack/requirements/blob/stable/rocky/upper-constraints.txt#L225

since stein it was updated to 2.4.0 so we updated it.

Btw, it was updated to 2.4.1 in master and stein, so we should also update.

Comment 32 Alfredo Moralejo 2019-08-02 10:33:58 UTC
I'm updating pysnmp in RDO Rocky in https://review.rdoproject.org/r/#/c/21697/

Comment 33 Alfredo Moralejo 2019-08-02 10:38:26 UTC
(In reply to John Dennis from comment #28)
> > We provide updates in RDO repos as you mentioned and those are pulled and
> > installed as they are newer that in RHEL/CentOS base. The problem is that
> > may be other packages in RHEL that use python-ldap and could be affected
> > by this update.
> 
> It's a risk but I can't see any other solution. Fortunately even though this
> is
> a major version upgrade according to the release notes the API changes for
> backward
> compatibility are minor, here is what I found:
> 
> The functions `ldap.open()`, `ldap.init()`, `ldif.CreateLDIF()`
> and `ldif.ParseLDIF()`, which were deprecated for over a decade,
> are scheduled for removal in python-ldap 3.1.
> 
> The module `ldap.async` is renamed to `ldap.asyncsearch`, due to
> `async` becoming a keyword in Python 3.7.
> The old module name is deprecated, but will be available as long
> as Python 3.6 is supported.
> 

yes, tbh, i'm more concerned with pyasn1 update that with python-ldap itself.

> > https://review.rdoproject.org/r/#/q/topic:update-ldap+(status:open+OR+status:merged)
> 
> Thank you, I think this is the right solution and the best first step in
> addressing the
> out of sync dependencies. At the moment we have a number of dependencies
> that need
> updating with respect to Keystone and we'll need to revisit this, but for
> now this
> is a good first step (I am going to review what was changed in ldappool just
> to make
> sure that doesn't have to update in lockstep with python-ldap.

Comment 55 Raildo Mascena de Sousa Filho 2019-12-05 20:38:11 UTC
hey David, 

We just applied the workaround described by the customer, removing the bytes_mode argument responsible for the check failure. You can find that change on openstack-keystone-14.1.1-0.20190514013954.00242bd.el7ost

Regards,

Comment 64 errata-xmlrpc 2019-12-20 01:13:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:4340


Note You need to log in before you can comment on or make changes to this bug.