RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1481949 - ipaserver uninstall in verbose mode displays "pkidestroy: ERROR.. subprocess.CalledProcessError: returned non-zero exit status 6!"
Summary: ipaserver uninstall in verbose mode displays "pkidestroy: ERROR.. subprocess....
Keywords:
Status: CLOSED DUPLICATE of bug 1902173
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: ipa
Version: 8.3
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: 8.4
Assignee: Thomas Woerner
QA Contact: ipa-qe
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-16 06:46 UTC by Sudhir Menon
Modified: 2021-01-06 09:07 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-01-06 09:07:36 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
pki-destroy log (29.82 KB, text/plain)
2017-08-16 06:49 UTC, Sudhir Menon
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Github dogtagpki pki issues 2924 0 None open ipaserver uninstall in verbose mode displays "pkidestroy: ERROR.. subprocess.CalledProcessError: returned non-zero exit... 2021-01-04 12:38:14 UTC

Description Sudhir Menon 2017-08-16 06:46:51 UTC
Description of problem:  ipa-server uninstall in verbose mode displays "pkidestroy  : ERROR    ....... subprocess.CalledProcessError: ....... returned non-zero exit status 6!" 


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 with verbose option. 

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

3. Check the message displayed on the console.

Actual results:

Configuring certmonger to stop tracking system certificates for KRA
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl start messagebus.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=
ipa         : DEBUG    stderr=
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl is-active messagebus.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=active

ipa         : DEBUG    stderr=
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl start certmonger.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=
ipa         : DEBUG    stderr=
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl is-active certmonger.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=active

ipa         : DEBUG    stderr=
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl stop certmonger.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=
ipa         : DEBUG    stderr=
ipa         : DEBUG    Loading StateFile from '/var/lib/ipa/sysrestore/sysrestore.state'
ipa         : DEBUG    Loading Index file from '/var/lib/ipa/sysrestore/sysrestore.index'
ipa         : DEBUG    Configuring certmonger to stop tracking system certificates for CA
Configuring certmonger to stop tracking system certificates for CA
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl start messagebus.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=
ipa         : DEBUG    stderr=
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl is-active messagebus.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=active

ipa         : DEBUG    stderr=
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl start certmonger.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=
ipa         : DEBUG    stderr=
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl is-active certmonger.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=active

ipa         : DEBUG    stderr=
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl stop certmonger.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=
ipa         : DEBUG    stderr=
ipa         : DEBUG    Loading StateFile from '/var/lib/ipa/sysrestore/sysrestore.state'
ipa         : DEBUG    Unconfiguring CA
Unconfiguring CA
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/usr/sbin/pkidestroy -i pki-tomcat -s CA
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=Log file: /var/log/pki/pki-ca-destroy.20170816023845.log
Loading deployment configuration from /var/lib/pki/pki-tomcat/ca/registry/ca/deployment.cfg.
Uninstalling CA from /var/lib/pki/pki-tomcat.
Uninstallation complete.

ipa         : DEBUG    stderr=pkidestroy  : WARNING  ....... this 'CA' entry will NOT be deleted from security domain 'IPA'!
pkidestroy  : WARNING  ....... security domain 'IPA' may be offline or unreachable!
pkidestroy  : ERROR    ....... subprocess.CalledProcessError:  Command '['/usr/bin/sslget', '-n', 'subsystemCert cert-pki-ca', '-p', '6Hl^?If%%~i{{iBB<x?k7Mri46:++uex|M:!!!MB|', '-d', '/etc/pki/pki-tomcat/alias', '-e', 'name="/var/lib/pki/pki-tomcat"&type=CA&list=caList&host=cypher.testrelm.test&sport=443&ncsport=443&adminsport=443&agentsport=443&operation=remove', '-v', '-r', '/ca/agent/ca/updateDomainXML', 'cypher.testrelm.test:443']' returned non-zero exit status 6!
ipa         : DEBUG    Loading StateFile from '/var/lib/ipa/sysrestore/sysrestore.state'
ipa         : DEBUG    Loading StateFile from '/var/lib/ipa/sysrestore/sysrestore.state'
ipa         : DEBUG    Saving StateFile to '/var/lib/ipa/sysrestore/sysrestore.state'
ipa         : DEBUG    Loading StateFile from '/var/lib/ipa/sysrestore/sysrestore.state'
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl start messagebus.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=
ipa         : DEBUG    stderr=
ipa         : DEBUG    Starting external process
ipa         : DEBUG    args=/bin/systemctl is-active messagebus.service
ipa         : DEBUG    Process finished, return code=0
ipa         : DEBUG    stdout=active

Expected results:
Fix the above error.

Additional info:

Comment 2 Sudhir Menon 2017-08-16 06:49:53 UTC
Created attachment 1313960 [details]
pki-destroy log

Comment 3 Petr Vobornik 2017-08-28 16:56:52 UTC
From triage:

The error happens in sslget - PKI tools and pkidestroy, moving to pki.

Comment 4 Matthew Harmsen 2017-10-25 16:25:58 UTC
[20171025] - RHEL 7.5 / RHCS 9.3 pre-Alpha Offline Triage ==> 7.6

Comment 5 Matthew Harmsen 2018-05-02 22:57:33 UTC
alee: this is old.  Is it still an issue?

Comment 6 Sudhir Menon 2018-05-04 06:10:16 UTC
I am still able to see the issue with the latest distro and the rpms mentioned below.

[root@master log]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.5 (Maipo)

ipa-server-4.5.4-10.el7_5.1.x86_64
389-ds-base-1.3.7.5-21.el7_5.x86_64
sssd-1.16.0-19.el7_5.1.x86_64
pki-server-10.5.1-11.el7.noarch
pki-ca-10.5.1-11.el7.noarch
krb5-server-1.15.1-19.el7.x86_64

---------------------
2018-05-03T13:19:53Z DEBUG stderr=
2018-05-03T13:19:59Z DEBUG Starting external process
2018-05-03T13:19:59Z DEBUG args=/bin/systemctl stop certmonger.service
2018-05-03T13:19:59Z DEBUG Process finished, return code=0
2018-05-03T13:19:59Z DEBUG stdout=
2018-05-03T13:19:59Z DEBUG stderr=
2018-05-03T13:19:59Z DEBUG Loading StateFile from '/var/lib/ipa/sysrestore/sysrestore.state'
2018-05-03T13:19:59Z DEBUG Unconfiguring CA
2018-05-03T13:19:59Z DEBUG Starting external process
2018-05-03T13:19:59Z DEBUG args=/usr/sbin/pkidestroy -i pki-tomcat -s CA
2018-05-03T13:20:00Z DEBUG Process finished, return code=0
2018-05-03T13:20:00Z DEBUG stdout=Log file: /var/log/pki/pki-ca-destroy.20180503185000.log
Loading deployment configuration from /var/lib/pki/pki-tomcat/ca/registry/ca/deployment.cfg.
WARNING: The 'pki_ssl_server_nickname' in [CA] has been deprecated. Use 'pki_sslserver_nickname' instead.
WARNING: The 'pki_ssl_server_subject_dn' in [CA] has been deprecated. Use 'pki_sslserver_subject_dn' instead.
Uninstalling CA from /var/lib/pki/pki-tomcat.

Uninstallation complete.

2018-05-03T13:20:00Z DEBUG stderr=pkidestroy  : WARNING  ....... this 'CA' entry will NOT be deleted from security domain 'IPA'!
pkidestroy  : WARNING  ....... security domain 'IPA' may be offline or unreachable!
pkidestroy  : ERROR    ....... subprocess.CalledProcessError:  Command '['/usr/bin/sslget', '-n', 'subsystemCert cert-pki-ca', '-p', '1Vu,Dr9Q!;oN5<x_fxq*QinokS{PTHZ]((:>1Hd!:', '-d', '/etc/pki/pki-tomcat/alias', '-e', 'name="/var/lib/pki/pki-tomcat"&type=CA&list=caList&host=master.testrelm.test&sport=443&ncsport=443&adminsport=443&agentsport=443&operation=remove', '-v', '-r', '/ca/agent/ca/updateDomainXML', 'master.testrelm.test:443']' returned non-zero exit status 6!
-----------------

Comment 7 Matthew Harmsen 2018-07-04 00:30:08 UTC
Moved to RHEL 7.7.

Comment 10 Alex Scheel 2020-11-16 21:18:59 UTC
Could I get some more information about how to reproduce this?


I started with these packages on F32:

 -  389-ds-base-1.4.3.15-1.fc32.x86_64
 -  freeipa-server-4.8.10-6.fc32.x86_64
 -  pki-base-10.10.0-2.fc32.noarch

I installed using this command:

# ipa-server-install -U -r "{{ realm|upper }}" -n "{{ domain }}" -p "{{ password }}" -a "{{ password }}" "--hostname={{ hostname }}.{{ domain }}" --setup-kra --setup-dns --auto-reverse "--forwarder={{ forwarder }}"

And then uninstalled:

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

And it appears to have worked.



Do I need any replicas or anything?

Comment 11 Marc Sauton 2020-11-18 01:37:29 UTC
this report is missing the scenario details, what was the IPA topology, and the IPA PKI services.

an error like this can happen:
when the replica is a subordinate CA to some other Dogtag CA, within the same security domain, and the issuer of that replica with a CA or KRA is offline, so the security domain is not available, and the PKI registry cannot be updated,
or if /etc/httpd/conf.d/ipa-pki-proxy.conf is missing the location match for /ca/agent/ca/updateDomainXML
or if the TCP port 443 is incorrect
so the final destination on TCP 8443 cannot be made to reach the CA services.


pkidestroy could be more robust:

pkidestroy provided 2 warning messages but sslget had a serious network connection error that prevented the security domain update:
"
pkidestroy  : WARNING  ....... this 'CA' entry will NOT be deleted from security domain 'IPA'!
pkidestroy  : WARNING  ....... security domain 'IPA' may be offline or unreachable!
"

the remote socket connection failed in 
./base/native-tools/src/sslget/sslget.c
do_connect(
...
    prStatus = PR_Connect(tcp_sock, addr, PR_SecondsToInterval(3));
    if (prStatus != PR_SUCCESS) {
        errWarn("PR_Connect");
        if( tcp_sock != NULL ) {
            PR_Close(tcp_sock);
            tcp_sock = NULL;
        }
        exit(6);
    }
...

the NSPR call PR_Connect returns either PR_SUCCESS or PR_FAILURE.
sslget error code 6 is like PR_FAILURE.

should pkidestroy exit before un-installing a subsystem when there is no PR_SUCCESS from the sslget to access the security domain?

it seem like
./base/server/python/pki/server/deployment/pkihelper.py
    def deregister(self, install_token, critical_failure=False):

goes into

        else:
            output = self.update_domain_using_agent_port(
                typeval, secname, params, update_url, sechost, secagentport,
                critical_failure)

        if not output:
            if critical_failure:
                raise Exception("Cannot update domain using agent port")
            else:
                return


to call update_domain_using_agent_port()
which had the sslget error 6, and sends the 2 warnings

        except subprocess.CalledProcessError as exc:
            config.pki_log.warning(
                log.PKIHELPER_SECURITY_DOMAIN_UPDATE_FAILURE_2,
                typeval,
                secname,
                extra=config.PKI_INDENTATION_LEVEL_2)
            config.pki_log.warning(
                log.PKIHELPER_SECURITY_DOMAIN_UNREACHABLE_1,
                secname,
                extra=config.PKI_INDENTATION_LEVEL_2)
            config.pki_log.error(log.PKI_SUBPROCESS_ERROR_1, exc,
                                 extra=config.PKI_INDENTATION_LEVEL_2)
            if critical_failure:
                raise

        return None 

and then returns nothing to deregister, which returns 0 to pkidestroy, which returns 0 to ipa-server-install --uninstall

so the failed TCP connection with the sslget error code 6 was not really fully processed.

pkidestroy should be able to handle the non 0 error codes like 6, and not run all the scriptlets to un-install a sub system, until the PKI registry / security domain info is available, should exit early in /usr/lib/python3.6/site-packages/pki/server/deployment/scriptlets/initialization.py

that may lead to some partial / incomplete PKI susbsystem removal that may not be removed at the next attempt.

and "ipa-server-install --uninstall" should first verify the PKI registry is available if there is a PKI subsystem installed, before proceeding with an un-install.

Comment 12 Alex Scheel 2020-11-18 18:47:36 UTC
But server uninstall won't fail anyways: the failure is treated as informational by PKI: 

https://github.com/dogtagpki/pki/blob/master/base/server/python/pki/server/deployment/pkihelper.py#L2347

critical_failure is set to False by default; no callers override it. 

That means we should log the exception and continue on:

https://github.com/dogtagpki/pki/blob/master/base/server/python/pki/server/deployment/pkihelper.py#L2414-L2415
https://github.com/dogtagpki/pki/blob/master/base/server/python/pki/server/deployment/scriptlets/initialization.py#L202-L217


AFAICT, this behavior has existed since the bug was originally filed. Indeed, the original bug just says "fix this error" -- but yet, it never _fails_ -- failure is logged so the admin can take appropriate action as required, but server uninstallation still succeeds.

This is completely a non-issue.

And, if force removal is what is desired, then IPA could pass --force to pkidestroy. Perhaps that's the best option?



My 2c, but this should be CLOSED -> NOTABUG.

Comment 13 Alex Scheel 2020-11-18 19:04:47 UTC
Note that tools to manage security domains have existed for a while. See bz#1740697 about an RFE if there are any changes necessary, but as I read it, if IPA gets out of sync from PKI, there's nothing more we can do (at uninstallation time) --- we already tried to contact SD and it failed. We have had the tools to fix this for a while. These tools should be used in the appropriate cases, or if IPA doesn't like direct usage of PKI tools, they should wrap them as appropriate.


I don't think it is appropriate to stop removal over failure to contact SD. For one, we have no way of indicating to ipa-server-install --uninstall (prior to execution of pkidestory) that destroy might fail due to SD removal. If it does fail, we leave the customer with a broken/partial uninstall. For two, this is really up to IPA to decide (whether failure to remove from SD should be fatal) and if so, IPA should attempt to contact SD owner prior to removal. If they need help in this regard, we're happy to help.

Comment 14 Rob Crittenden 2020-11-18 19:14:45 UTC
We can't make the call on how fatal not updating the SD is. The CA is a black box. If we need to do something prior to uninstall then we'll do it.

IPA could call pki securitydomain-host-show prior to beginning the uninstall, for example, and fail if the connection fails and abort the entire uninstall.

Comment 15 Alex Scheel 2020-11-18 20:21:50 UTC
Summarizing comments on #ipa...

Security Domain will never be contactable in an IPA scenario. This is because IPA shuts down all services prior to initiating uninstallation. Because IPA provisions the security domain with port 443 for access and turns off httpd prior to calling pkidestroy, pkidestroy will never be able to contact the security domain.

When ipa-server-install is called, and then pkidestroy is run manually, this failure doesn't manifest.

Thus re-assigning to IPA. PKI should provide a list of services which should still be enabled at the time it is shut down. Probably these include:

 - pki-tomcat
 - Directory server instance
 - httpd (for port 443 as configured in the SD config).


See https://github.com/freeipa/freeipa/blob/master/ipaserver/install/dogtaginstance.py#L820 for sd port configuration. 


So, SD likely hasn't ever been removed from IPA deploys and they get badly out of sync.

Christina, Jack, what's the consequence of this?

Comment 18 Christina Fu 2020-11-18 21:42:23 UTC
Alex, I agree with your assessment in https://bugzilla.redhat.com/show_bug.cgi?id=1740697#c6
Although I have not tried pki securitydomain-host myself, but if it works as advertised, and if it's an acceptable operation by IPA to manually fix the SD content, it might be sufficient for such corner cases.

The consequences of things out of sync in SD would be if one wishes to intall another instance in the SD, incorrect info would be provided.  E.g. an KRA that's already uninstalled would appear to be selectable.  Although I'm uncertain at what point the error would be discovered.

Comment 22 Petr Čech 2021-01-06 09:07:36 UTC

*** This bug has been marked as a duplicate of bug 1902173 ***


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