pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0008-Fix_misleading_errors_during_client_install_rollback_rhbz#1658283.patch

6d47df
From c64030a357401467d74e77d610d3bc268412220d Mon Sep 17 00:00:00 2001
6d47df
From: Rob Crittenden <rcritten@redhat.com>
6d47df
Date: Tue, 16 Oct 2018 13:58:00 -0400
6d47df
Subject: [PATCH] Remove the authselect profile warning if sssd was not
6d47df
 configured.
6d47df
6d47df
On a plain uninstall there should not be a bunch of confusing
6d47df
warning/error messages.
6d47df
6d47df
Related to https://pagure.io/freeipa/issue/7729
6d47df
6d47df
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
6d47df
Reviewed-By: Christian Heimes <cheimes@redhat.com>
6d47df
---
6d47df
 ipatests/test_integration/test_authselect.py | 1 -
6d47df
 1 file changed, 1 deletion(-)
6d47df
6d47df
diff --git a/ipatests/test_integration/test_authselect.py b/ipatests/test_integration/test_authselect.py
6d47df
index 5eb3fdbf02..5ce56fa21e 100644
6d47df
--- a/ipatests/test_integration/test_authselect.py
6d47df
+++ b/ipatests/test_integration/test_authselect.py
6d47df
@@ -136,7 +136,6 @@ def test_uninstall_client_no_preconfigured_profile(self):
6d47df
         # by default
6d47df
         result = self._uninstall_client()
6d47df
         assert result.returncode == 0
6d47df
-        assert self.msg_warn_uninstall in result.stderr_text
6d47df
         check_authselect_profile(self.client, default_profile)
6d47df
 
6d47df
     def test_install_client_preconfigured_profile(self):
6d47df
From ec5e821f05cbc20517af6c9578e813f1963a9e8c Mon Sep 17 00:00:00 2001
6d47df
From: Rob Crittenden <rcritten@redhat.com>
6d47df
Date: Wed, 10 Oct 2018 14:07:33 -0400
6d47df
Subject: [PATCH] Fix misleading errors during client install rollback
6d47df
6d47df
Some incorrect errors are possible if a client installation
6d47df
fails and a configuration rollback is required.
6d47df
6d47df
These include:
6d47df
6d47df
1. Unconfigured automount client failed: CalledProcessError(Command
6d47df
['/usr/sbin/ipa-client-automount', '--uninstall', '--debug']
6d47df
returned non-zero exit status 1: '')
6d47df
6d47df
Caused by check_client_configuration() not returning the correct
6d47df
return value (2).
6d47df
6d47df
2. WARNING: Unable to revert to the pre-installation state ('authconfig'
6d47df
tool has been deprecated in favor of 'authselect'). The default sssd
6d47df
profile will be used instead.
6d47df
The authconfig arguments would have been: authconfig --disableldap
6d47df
--disablekrb5 --disablesssdauth --disablemkhomedir
6d47df
6d47df
If installation fails before SSSD is configured there is no state
6d47df
to roll back to. Detect this condition.
6d47df
6d47df
3. An error occurred while removing SSSD's cache.Please remove the
6d47df
cache manually by executing sssctl cache-remove -o.
6d47df
6d47df
Again, if SSSD is not configured yet then there is no cache to
6d47df
remove. Also correct the missing space after the period.
6d47df
6d47df
https://pagure.io/freeipa/issue/7729
6d47df
6d47df
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
6d47df
Reviewed-By: Christian Heimes <cheimes@redhat.com>
6d47df
---
6d47df
 ipaclient/install/client.py                   | 18 ++++++-----
6d47df
 ipalib/util.py                                |  5 +++-
6d47df
 ipaplatform/redhat/authconfig.py              |  2 +-
6d47df
 .../test_replica_promotion.py                 | 30 +++++++++++++++++++
6d47df
 4 files changed, 45 insertions(+), 10 deletions(-)
6d47df
6d47df
diff --git a/ipaclient/install/client.py b/ipaclient/install/client.py
6d47df
index 0dcd1ec744..05255fe61b 100644
6d47df
--- a/ipaclient/install/client.py
6d47df
+++ b/ipaclient/install/client.py
6d47df
@@ -3284,13 +3284,14 @@ def uninstall(options):
6d47df
     remove_file(paths.SSSD_MC_GROUP)
6d47df
     remove_file(paths.SSSD_MC_PASSWD)
6d47df
 
6d47df
-    try:
6d47df
-        run([paths.SSSCTL, "cache-remove", "-o", "--stop", "--start"])
6d47df
-    except Exception:
6d47df
-        logger.info(
6d47df
-            "An error occurred while removing SSSD's cache."
6d47df
-            "Please remove the cache manually by executing "
6d47df
-            "sssctl cache-remove -o.")
6d47df
+    if was_sssd_installed:
6d47df
+        try:
6d47df
+            run([paths.SSSCTL, "cache-remove", "-o", "--stop", "--start"])
6d47df
+        except Exception:
6d47df
+            logger.info(
6d47df
+                "An error occurred while removing SSSD's cache."
6d47df
+                "Please remove the cache manually by executing "
6d47df
+                "sssctl cache-remove -o.")
6d47df
 
6d47df
     if ipa_domain:
6d47df
         sssd_domain_ldb = "cache_" + ipa_domain + ".ldb"
6d47df
@@ -3354,7 +3355,8 @@ def uninstall(options):
6d47df
 
6d47df
     # SSSD was not installed before our installation, and no other domains
6d47df
     # than IPA are configured in sssd.conf - make sure config file is removed
6d47df
-    elif not was_sssd_installed and not was_sssd_configured:
6d47df
+    elif not was_sssd_installed and not was_sssd_configured \
6d47df
+            and os.path.exists(paths.SSSD_CONF):
6d47df
         try:
6d47df
             os.rename(paths.SSSD_CONF, paths.SSSD_CONF_DELETED)
6d47df
         except OSError:
6d47df
diff --git a/ipalib/util.py b/ipalib/util.py
6d47df
index 3e8fab49d6..68857baec7 100644
6d47df
--- a/ipalib/util.py
6d47df
+++ b/ipalib/util.py
6d47df
@@ -1125,11 +1125,14 @@ def ensure_krbcanonicalname_set(ldap, entry_attrs):
6d47df
 def check_client_configuration():
6d47df
     """
6d47df
     Check if IPA client is configured on the system.
6d47df
+
6d47df
+    Hardcode return code to avoid recursive imports
6d47df
     """
6d47df
     if (not os.path.isfile(paths.IPA_DEFAULT_CONF) or
6d47df
             not os.path.isdir(paths.IPA_CLIENT_SYSRESTORE) or
6d47df
             not os.listdir(paths.IPA_CLIENT_SYSRESTORE)):
6d47df
-        raise ScriptError('IPA client is not configured on this system')
6d47df
+        raise ScriptError('IPA client is not configured on this system',
6d47df
+                          2)  # CLIENT_NOT_CONFIGURED
6d47df
 
6d47df
 
6d47df
 def check_principal_realm_in_trust_namespace(api_instance, *keys):
6d47df
diff --git a/ipaplatform/redhat/authconfig.py b/ipaplatform/redhat/authconfig.py
6d47df
index ab3775e9e9..e456d9ec6e 100644
6d47df
--- a/ipaplatform/redhat/authconfig.py
6d47df
+++ b/ipaplatform/redhat/authconfig.py
6d47df
@@ -141,7 +141,7 @@ def configure(self, sssd, mkhomedir, statestore, sudo=True):
6d47df
     def unconfigure(
6d47df
         self, fstore, statestore, was_sssd_installed, was_sssd_configured
6d47df
     ):
6d47df
-        if not statestore.has_state('authselect'):
6d47df
+        if not statestore.has_state('authselect') and was_sssd_installed:
6d47df
             logger.warning(
6d47df
                 "WARNING: Unable to revert to the pre-installation state "
6d47df
                 "('authconfig' tool has been deprecated in favor of "
6d47df
diff --git a/ipatests/test_integration/test_replica_promotion.py b/ipatests/test_integration/test_replica_promotion.py
6d47df
index 265cbfb139..7803c34dcc 100644
6d47df
--- a/ipatests/test_integration/test_replica_promotion.py
6d47df
+++ b/ipatests/test_integration/test_replica_promotion.py
6d47df
@@ -207,6 +207,36 @@ def test_upcase_client_domain(self):
6d47df
         assert(result1.returncode == 0), (
6d47df
             'Failed to promote the client installed with the upcase domain name')
6d47df
 
6d47df
+    def test_client_rollback(self):
6d47df
+        """Test that bogus error msgs are not in output on rollback.
6d47df
+
6d47df
+           FIXME: including in this suite to avoid setting up a
6d47df
+                  master just to test a client install failure. If
6d47df
+                  a pure client install suite is added this can be
6d47df
+                  moved.
6d47df
+
6d47df
+           Ticket https://pagure.io/freeipa/issue/7729
6d47df
+        """
6d47df
+        client = self.replicas[0]
6d47df
+
6d47df
+        # Cleanup previous run
6d47df
+        client.run_command(['ipa-server-install',
6d47df
+                            '--uninstall', '-U'], raiseonerr=False)
6d47df
+
6d47df
+        result = client.run_command(['ipa-client-install', '-U',
6d47df
+                                     '--server', self.master.hostname,
6d47df
+                                     '--domain', client.domain.name,
6d47df
+                                     '-w', 'foo'], raiseonerr=False)
6d47df
+
6d47df
+        assert(result.returncode == 1)
6d47df
+
6d47df
+        assert("Unconfigured automount client failed" not in
6d47df
+               result.stdout_text)
6d47df
+
6d47df
+        assert("WARNING: Unable to revert" not in result.stdout_text)
6d47df
+
6d47df
+        assert("An error occurred while removing SSSD" not in
6d47df
+               result.stdout_text)
6d47df
 
6d47df
 class TestRenewalMaster(IntegrationTest):
6d47df
 
6d47df
From db960e32f155412c34807e204add4858090d3e94 Mon Sep 17 00:00:00 2001
6d47df
From: Rob Crittenden <rcritten@redhat.com>
6d47df
Date: Tue, 16 Oct 2018 14:07:25 -0400
6d47df
Subject: [PATCH] Collect the client and server uninstall logs in tests
6d47df
6d47df
When running the integration tests capture the uninstallation
6d47df
logs as well as the installation logs.
6d47df
6d47df
Reviewed-By: Christian Heimes <cheimes@redhat.com>
6d47df
---
6d47df
 ipatests/pytest_ipa/integration/tasks.py | 3 ++-
6d47df
 1 file changed, 2 insertions(+), 1 deletion(-)
6d47df
6d47df
diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py
6d47df
index f0c61381b6..620ed28c96 100644
6d47df
--- a/ipatests/pytest_ipa/integration/tasks.py
6d47df
+++ b/ipatests/pytest_ipa/integration/tasks.py
6d47df
@@ -69,11 +69,12 @@ def setup_server_logs_collecting(host):
6d47df
 
6d47df
     # IPA install logs
6d47df
     host.collect_log(paths.IPASERVER_INSTALL_LOG)
6d47df
+    host.collect_log(paths.IPASERVER_UNINSTALL_LOG)
6d47df
     host.collect_log(paths.IPACLIENT_INSTALL_LOG)
6d47df
+    host.collect_log(paths.IPACLIENT_UNINSTALL_LOG)
6d47df
     host.collect_log(paths.IPAREPLICA_INSTALL_LOG)
6d47df
     host.collect_log(paths.IPAREPLICA_CONNCHECK_LOG)
6d47df
     host.collect_log(paths.IPAREPLICA_CA_INSTALL_LOG)
6d47df
-    host.collect_log(paths.IPACLIENT_INSTALL_LOG)
6d47df
     host.collect_log(paths.IPASERVER_KRA_INSTALL_LOG)
6d47df
     host.collect_log(paths.IPA_CUSTODIA_AUDIT_LOG)
6d47df