Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1428472 - batch param compatibility is incorrect
batch param compatibility is incorrect
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: ipa (Show other bugs)
7.3
Unspecified Unspecified
urgent Severity urgent
: rc
: ---
Assigned To: IPA Maintainers
Nikhil Dehadrai
: ZStream
Depends On:
Blocks: 1430674
  Show dependency treegraph
 
Reported: 2017-03-02 11:15 EST by Petr Vobornik
Modified: 2017-08-01 05:44 EDT (History)
8 users (show)

See Also:
Fixed In Version: ipa-4.4.0-14.el7.7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1430674 (view as bug list)
Environment:
Last Closed: 2017-08-01 05:44:33 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:2304 normal SHIPPED_LIVE ipa bug fix and enhancement update 2017-08-01 08:41:35 EDT

  None (edit)
Description Petr Vobornik 2017-03-02 11:15:02 EST
The definition of the batch params all define methods as Str. It has never been a Str. It was defined as Any until recently when it was refined to Dict.

This causes the batch command in ipalib on 4.4 to fail to work because methods is not a Str (it doesn't even get far enough to make a request, it blows up validating the input).

Here is the output from the sample program:
Traceback (most recent call last):
  File "batch.py", line 10, in <module>
    res = api.Command.batch(batch)
  File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 449, in __call__
    return self.__do_call(*args, **options)
  File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 470, in __do_call
    params = self.convert(**params)
  File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 671, in convert
    (k, self.params[k].convert(v)) for (k, v) in kw.items()
  File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 671, in <genexpr>
    (k, self.params[k].convert(v)) for (k, v) in kw.items()
  File "/usr/lib/python2.7/site-packages/ipalib/parameters.py", line 831, in convert
    convert(v) for v in value if not _is_null(v)
  File "/usr/lib/python2.7/site-packages/ipalib/parameters.py", line 831, in <genexpr>
    convert(v) for v in value if not _is_null(v)
  File "/usr/lib/python2.7/site-packages/ipalib/parameters.py", line 1445, in _convert_scalar
    raise ConversionError(name=self.name, error=ugettext(self.type_error))
ipalib.errors.ConversionError: invalid 'methods': must be Unicode text



Reproducer (python script):

from ipalib import api
from ipalib import errors

api.bootstrap(context='cli')
api.finalize()
api.Backend.rpcclient.connect()

batch = [{u'params': [(u'test.example.com',), {u'force': u'True'}], u'method': u'host_add'}]

res = api.Command.batch(batch)


Expected result:

Commands are executed, command returns res and doesn't throw exception.
Comment 1 Petr Vobornik 2017-03-02 11:16:15 EST
Upstream ticket:
https://pagure.io/freeipa/issue/6647
Comment 2 Petr Vobornik 2017-03-02 11:17:10 EST
master:
    19060db1b8fa9d1d3e8f3ac3fcd1f387e9a39c94 compat: fix Any params in batch and dnsrecord
Comment 6 Jan Cholasta 2017-03-14 01:27:38 EDT
Fixed upstream
ipa-4-4:
https://pagure.io/freeipa/c/e3b49abfe7a8d9540d77ed355595d9e44a3bdd27
Comment 8 Nikhil Dehadrai 2017-05-09 07:16:38 EDT
IPA server version:  ipa-server-4.5.0-10.el7.x86_64

Verified the bug on the basis of following steps performed on IPA-server setup on pre4.4 (In my case RHEL 7.2.z) version and IPA-client on latest version (RHEL 7.4):

IPA MASTER:
============
[root@intel-sugarbay-do-01 ~]# rpm -qa ipa-server
ipa-server-4.2.0-15.el7_2.19.x86_64
[root@intel-sugarbay-do-01 ~]# ## THIS is IPA-SERVER
[root@intel-sugarbay-do-01 ~]# ipactl status
Directory Service: RUNNING
krb5kdc Service: RUNNING
kadmin Service: RUNNING
named Service: RUNNING
ipa_memcached Service: RUNNING
httpd Service: RUNNING
pki-tomcatd Service: RUNNING
ipa-otpd Service: RUNNING
ipa-dnskeysyncd Service: RUNNING
ipa: INFO: The ipactl command was successful
[root@intel-sugarbay-do-01 ~]# ipa host-find test.example.com
ipa: ERROR: did not receive Kerberos credentials
[root@intel-sugarbay-do-01 ~]# kinit admin
Password for admin@TESTRELM.TEST: 
[root@intel-sugarbay-do-01 ~]# ipa host-find test.example.com
---------------
0 hosts matched
---------------
----------------------------
Number of entries returned 0
----------------------------



IPA-CLIENT:
=============
[root@cloud-qe-15 ~]# rpm -q ipa-client
ipa-client-4.5.0-10.el7.x86_64
[root@cloud-qe-15 ~]# kinit admin
Password for admin@TESTRELM.TEST: 
[root@cloud-qe-15 ~]# ipa host-find test.example.com
---------------
0 hosts matched
---------------
----------------------------
Number of entries returned 0
----------------------------
[root@cloud-qe-15 ~]# cat test.py 
from ipalib import api
from ipalib import errors

api.bootstrap(context='cli')
api.finalize()
api.Backend.rpcclient.connect()

batch = [{u'params': [(u'test.example.com',), {u'force': u'True'}], u'method': u'host_add'}]

res = api.Command.batch(batch)
[root@cloud-qe-15 ~]# python test.py 
[root@cloud-qe-15 ~]# ipa host-find test.example.com
--------------
1 host matched
--------------
  Host name: test.example.com
  Principal name: host/test.example.com@TESTRELM.TEST
  Password: False
  Keytab: False
  Managed by: test.example.com
----------------------------
Number of entries returned 1
----------------------------

IPA MASTER:
============
Now re-run "ipa host-find" on master:

[root@intel-sugarbay-do-01 ~]# ipa host-find test.example.com
--------------
1 host matched
--------------
  Host name: test.example.com
  Principal name: host/test.example.com@TESTRELM.TEST
  Password: False
  Keytab: False
  Managed by: test.example.com
----------------------------
Number of entries returned 1
----------------------------

Thus on the basis of above steps, marking the status of bug to "VERIFIED"
Comment 9 errata-xmlrpc 2017-08-01 05:44:33 EDT
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-2017:2304

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