Bug 1480502

Summary: ipa server uninstall with -v option displays "IOError: [Errno 9] Bad file descriptor Logged from file ipautil.py, line 442"
Product: Red Hat Enterprise Linux 7 Reporter: Sudhir Menon <sumenon>
Component: ipaAssignee: IPA Maintainers <ipa-maint>
Status: CLOSED ERRATA QA Contact: ipa-qe <ipa-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: cheimes, frenaud, lmiksik, ndehadra, pasik, pvoborni, rcritten, slaznick, tdudlak, tscherf
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ipa-4.6.4-7.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 10:56:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Uninstall Log none

Description Sudhir Menon 2017-08-11 09:27:58 UTC
Description of problem: ipa server uninstall with -v option displays "IOError: [Errno 9] Bad file descriptor Logged from file ipautil.py, line 442"


Version-Release number of selected component (if applicable):
ipa-server-4.5.0-21.el7_4.1.x86_64

How reproducible:Always


Steps to Reproduce:
1. Install IPA server
2. Uninstall ipa-server using the verbose option

#ipa-server-install --uninstall -U -v

Actual results: The console log displays the below message.

1. Check the below section
ipa         : DEBUG    stderr=
ipa         : DEBUG    Removing service keytab: /etc/dirsrv/ds.keytab
ipa         : DEBUG    Removing service credentials cache
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/usr/bin/kdestroy
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=
ipa         : DEBUG    stderr=Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 875, in emit
    self.flush()
  File "/usr/lib64/python2.7/logging/__init__.py", line 835, in flush
    self.stream.flush()
IOError: [Errno 9] Bad file descriptor
Logged from file ipautil.py, line 442
ipa         : DEBUG    runas=dirsrv (UID 389, GID 389)

=========

2. Check the traceback seen at the end of the uninstall section.
ipa         : DEBUG    Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ipapython/install/common.py", line 91, in _handle_execute_exception
    super(Continuous, self)._handle_execute_exception(exc_info)
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 463, in _handle_execute_exception
    self._handle_exception(exc_info)
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 453, in _handle_exception
    six.reraise(*exc_info)
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 424, in __runner
    step()
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 421, in <lambda>
    step = lambda: next(self.__gen)
  File "/usr/lib/python2.7/site-packages/ipapython/install/util.py", line 81, in run_generator_with_yield_from
    six.reraise(*exc_info)
  File "/usr/lib/python2.7/site-packages/ipapython/install/util.py", line 59, in run_generator_with_yield_from
    value = gen.send(prev_value)
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 658, in _configure
    next(executor)
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 434, in __runner
    exc_handler(exc_info)
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 463, in _handle_execute_exception
    self._handle_exception(exc_info)
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 521, in _handle_exception
    self.__parent._handle_exception(exc_info)
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 453, in _handle_exception
    six.reraise(*exc_info)
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 518, in _handle_exception
    super(ComponentBase, self)._handle_exception(exc_info)
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 453, in _handle_exception
    six.reraise(*exc_info)
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 424, in __runner
    step()
  File "/usr/lib/python2.7/site-packages/ipapython/install/core.py", line 421, in <lambda>
    step = lambda: next(self.__gen)
  File "/usr/lib/python2.7/site-packages/ipapython/install/util.py", line 81, in run_generator_with_yield_from
    six.reraise(*exc_info)
  File "/usr/lib/python2.7/site-packages/ipapython/install/util.py", line 59, in run_generator_with_yield_from
    value = gen.send(prev_value)
  File "/usr/lib/python2.7/site-packages/ipapython/install/common.py", line 71, in _uninstall
    for _nothing in self._uninstaller(self.parent):
  File "/usr/lib/python2.7/site-packages/ipaserver/install/server/__init__.py", line 584, in main
    uninstall(self)
  File "/usr/lib/python2.7/site-packages/ipaserver/install/server/install.py", line 248, in decorated
    func(installer)
  File "/usr/lib/python2.7/site-packages/ipaserver/install/server/install.py", line 1160, in uninstall
    sys.exit(rv)
SystemExit: 0

Expected results: 

1. Although it doesn't seem to break anything, we should fix the above traceback seen.

2. Although the 'SystemExit: 0', if possible we should also fix the traceback to have a clean uninstall log file which doesn't confuse the end user.


Additional info:

Comment 2 Sudhir Menon 2017-08-16 06:42:56 UTC
ipa         : DEBUG    Removing service keytab: /etc/named.keytab
ipa         : DEBUG    Removing service credentials cache
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/usr/bin/kdestroy
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=
ipa         : DEBUG    stderr=Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 875, in emit
    self.flush()
  File "/usr/lib64/python2.7/logging/__init__.py", line 835, in flush
    self.stream.flush()
IOError: [Errno 9] Bad file descriptor
Logged from file ipautil.py, line 442
ipa         : DEBUG    runas=named (UID 25, GID 25)

ipa         : DEBUG    Loading StateFile from '/var/lib/ipa/sysrestore/sysrestore.state'
ipa         : DEBUG    Unconfiguring ipa-dnskeysyncd

Comment 3 Petr Vobornik 2017-08-18 16:33:09 UTC
Was this already fixed upstream?

Comment 4 Standa Laznicka 2017-08-21 12:02:39 UTC
This is fixed in FreeIPA master branch. A fix should arrive in RHEL 7.6 since the fix was a part of a major refactoring.

Comment 11 Sudhir Menon 2018-08-07 10:19:08 UTC
Tested on Red Hat Enterprise Linux Server release 7.6 Beta (Maipo)  using
ipa-server-4.6.4-3.el7.x86_64
sssd-1.16.2-11.el7.x86_64
389-ds-base-1.3.8.4-9.el7.x86_64
krb5-server-1.15.1-34.el7.x86_64
pki-server-10.5.9-4.el7.noarch
selinux-policy-3.13.1-211.el7.noarch

Note:
1. There are certain traceback's which are yet to be addressed e.g as mentioned in comment#2 hence reopening the bug.

ipaserver.install.installutils: DEBUG    Removing service keytab: /etc/named.keytab
ipaserver.install.installutils: DEBUG    Removing service credentials cache
ipapython.ipautil: DEBUG    Starting external process
ipapython.ipautil: DEBUG    args=/usr/bin/kdestroy
ipapython.ipautil: DEBUG    Process finished, return code=0
ipapython.ipautil: DEBUG    stdout=
ipapython.ipautil: DEBUG    stderr=Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 875, in emit
    self.flush()
  File "/usr/lib64/python2.7/logging/__init__.py", line 835, in flush
    self.stream.flush()
IOError: [Errno 9] Bad file descriptor
Logged from file ipautil.py, line 493
ipapython.ipautil: DEBUG    runas=named (UID 25, GID 25)
----------------------------------
ipapython.ipautil: DEBUG    stderr=Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 875, in emit
    self.flush()
  File "/usr/lib64/python2.7/logging/__init__.py", line 835, in flush
    self.stream.flush()
IOError: [Errno 9] Bad file descriptor
Logged from file ipautil.py, line 493
ipapython.ipautil: DEBUG    runas=dirsrv (UID 994, GID 991)

Comment 12 Sudhir Menon 2018-08-07 10:20:45 UTC
Created attachment 1473945 [details]
Uninstall Log

Comment 13 Florence Blanc-Renaud 2018-08-23 08:57:13 UTC
Removing the NOUPSTREAM label as the issue needs a new fix.

Comment 14 Florence Blanc-Renaud 2018-08-23 09:03:56 UTC
Upstream ticket:
https://pagure.io/freeipa/issue/7681

Comment 21 Sudhir Menon 2018-09-03 13:39:19 UTC
Tested on Red Hat Enterprise Linux Server release 7.6 Beta (Maipo) using

ipa-server-4.6.4-7.el7.x86_64
sssd-1.16.2-12.el7.x86_64
samba-4.8.3-4.el7.x86_64
389-ds-base-1.3.8.4-12.el7.x86_64
pki-server-10.5.9-6.el7.noarch
ipa-client-4.6.4-7.el7.x86_64


Observations
1. IOError is no more seen.
2. traceback is also not seen at the end of uninstall log file.
3. For 'returned non-zero exit status 6!' bz1481949 has already been logged.

ipapython.ipautil: DEBUG    stderr=Removed symlink /etc/systemd/system/named.service.
ipaserver.install.installutils: DEBUG    Removing service keytab: /etc/named.keytab
ipaserver.install.installutils: DEBUG    Removing service credentials cache
ipapython.ipautil: DEBUG    Starting external process
ipapython.ipautil: DEBUG    args=/usr/bin/kdestroy
ipapython.ipautil: DEBUG    runas=named (UID 25, GID 25)
ipapython.ipautil: DEBUG    Process finished, return code=0
ipapython.ipautil: DEBUG    stdout=
ipapython.ipautil: DEBUG    stderr=
ipalib.install.sysrestore: DEBUG    Loading StateFile from '/var/lib/ipa/sysrestore/sysrestore.state'
ipaserver.install.service: DEBUG    Unconfiguring ipa-dnskeysyncd
Unconfiguring ipa-dnskeysyncd

ipapython.ipautil: DEBUG    stderr=
ipaserver.install.installutils: DEBUG    Removing service keytab: /etc/dirsrv/ds.keytab
ipaserver.install.installutils: DEBUG    Removing service credentials cache
ipapython.ipautil: DEBUG    Starting external process
ipapython.ipautil: DEBUG    args=/usr/bin/kdestroy
ipapython.ipautil: DEBUG    runas=dirsrv (UID 994, GID 990)
ipapython.ipautil: DEBUG    Process finished, return code=0

Systemwide CA database updated.
Client uninstall complete.
The ipa-client-install command was successful
ipapython.ipautil: DEBUG    Process finished, return code=0
ipapython.admintool: INFO     The ipa-server-install command was successful

Comment 23 errata-xmlrpc 2018-10-30 10:56:00 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-2018:3187