pgreco / rpms / ipa

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

Blame SOURCES/0025-ipa-client-automount_and_NFS_unit_name_changes_rhbz#1645501.patch

6d47df
From 65f6c8dc2585144b17ff89e63e4ba300971996dd Mon Sep 17 00:00:00 2001
6d47df
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
6d47df
Date: Thu, 6 Dec 2018 16:10:00 +0100
6d47df
Subject: [PATCH] Fix NFS unit names
6d47df
MIME-Version: 1.0
6d47df
Content-Type: text/plain; charset=UTF-8
6d47df
Content-Transfer-Encoding: 8bit
6d47df
6d47df
NFS unit names were renamed.
6d47df
Compatibility was maintained with older unit names
6d47df
through symlinks. When these symlinks are removed
6d47df
only new unit names work, so changing to using non-
6d47df
symlink unit names is required.
6d47df
6d47df
Fixes: https://pagure.io/freeipa/issue/7783
6d47df
Signed-off-by: François Cami <fcami@redhat.com>
6d47df
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
6d47df
---
6d47df
 ipaplatform/redhat/services.py | 4 ++--
6d47df
 1 file changed, 2 insertions(+), 2 deletions(-)
6d47df
6d47df
diff --git a/ipaplatform/redhat/services.py b/ipaplatform/redhat/services.py
6d47df
index 390bbb0231..20395aee44 100644
6d47df
--- a/ipaplatform/redhat/services.py
6d47df
+++ b/ipaplatform/redhat/services.py
6d47df
@@ -45,8 +45,8 @@
6d47df
 redhat_system_units = dict((x, "%s.service" % x)
6d47df
                            for x in base_services.wellknownservices)
6d47df
 
6d47df
-redhat_system_units['rpcgssd'] = 'nfs-secure.service'
6d47df
-redhat_system_units['rpcidmapd'] = 'nfs-idmap.service'
6d47df
+redhat_system_units['rpcgssd'] = 'rpc-gssd.service'
6d47df
+redhat_system_units['rpcidmapd'] = 'nfs-idmapd.service'
6d47df
 redhat_system_units['domainname'] = 'nis-domainname.service'
6d47df
 
6d47df
 # Rewrite dirsrv and pki-tomcatd services as they support instances via separate
6d47df
From 0687e4869995842a90d5d656749de42daceb2ad4 Mon Sep 17 00:00:00 2001
6d47df
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
6d47df
Date: Thu, 6 Dec 2018 17:29:26 +0100
6d47df
Subject: [PATCH] ipa-client-automount: use nfs-utils unit
6d47df
MIME-Version: 1.0
6d47df
Content-Type: text/plain; charset=UTF-8
6d47df
Content-Transfer-Encoding: 8bit
6d47df
6d47df
- remove nfs-idmapd from units we enable & start as:
6d47df
  - it is not used on NFS clients anymore
6d47df
  - it is a static unit
6d47df
- remove rpc-gssd as well as it is a static unit
6d47df
- restart nfs-utils and rpc-gssd
6d47df
- manage systemctl-related exceptions during uninstall
6d47df
6d47df
Fixes: https://pagure.io/freeipa/issue/7780
6d47df
Fixes: https://pagure.io/freeipa/issue/7781
6d47df
Signed-off-by: François Cami <fcami@redhat.com>
6d47df
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
6d47df
---
6d47df
 client/ipa-client-automount.in | 55 +++++++++++-----------------------
6d47df
 ipaplatform/base/services.py   |  3 +-
6d47df
 2 files changed, 20 insertions(+), 38 deletions(-)
6d47df
 mode change 100644 => 100755 client/ipa-client-automount.in
6d47df
6d47df
diff --git a/client/ipa-client-automount.in b/client/ipa-client-automount.in
6d47df
old mode 100644
6d47df
new mode 100755
6d47df
index 7348e20775..15926bd028
6d47df
--- a/client/ipa-client-automount.in
6d47df
+++ b/client/ipa-client-automount.in
6d47df
@@ -314,23 +314,21 @@ def uninstall(fstore, statestore):
6d47df
                 print('Unable to restore SSSD configuration: %s' % str(e))
6d47df
                 logger.debug('Unable to restore SSSD configuration: %s',
6d47df
                              str(e))
6d47df
+ 
6d47df
+    # rpcidmapd and rpcgssd are static units now
6d47df
     if statestore.has_state('rpcidmapd'):
6d47df
-        enabled = statestore.restore_state('rpcidmapd', 'enabled')
6d47df
-        running = statestore.restore_state('rpcidmapd', 'running')
6d47df
-        rpcidmapd = services.knownservices.rpcidmapd
6d47df
-        if not enabled:
6d47df
-            rpcidmapd.disable()
6d47df
-        if not running:
6d47df
-            rpcidmapd.stop()
6d47df
+        statestore.delete_state('rpcidmapd','enabled')
6d47df
+        statestore.delete_state('rpcidmapd','running')
6d47df
     if statestore.has_state('rpcgssd'):
6d47df
-        enabled = statestore.restore_state('rpcgssd', 'enabled')
6d47df
-        running = statestore.restore_state('rpcgssd', 'running')
6d47df
-        rpcgssd = services.knownservices.rpcgssd
6d47df
-        if not enabled:
6d47df
-            rpcgssd.disable()
6d47df
-        if not running:
6d47df
-            rpcgssd.stop()
6d47df
+        statestore.delete_state('rpcgssd','enabled')
6d47df
+        statestore.delete_state('rpcgssd','running')
6d47df
 
6d47df
+    nfsutils = services.knownservices['nfs-utils']
6d47df
+    try:
6d47df
+        nfsutils.restart()
6d47df
+    except Exception as e:
6d47df
+        logger.error("Failed to restart nfs client services (%s)" % str(e))
6d47df
+        return 1
6d47df
     return 0
6d47df
 
6d47df
 def configure_nfs(fstore, statestore):
6d47df
@@ -365,35 +363,18 @@ def configure_nfs(fstore, statestore):
6d47df
 
6d47df
     print("Configured %s" % paths.IDMAPD_CONF)
6d47df
 
6d47df
-    rpcidmapd = services.knownservices.rpcidmapd
6d47df
-    statestore.backup_state('rpcidmapd', 'enabled', rpcidmapd.is_enabled())
6d47df
-    statestore.backup_state('rpcidmapd', 'running', rpcidmapd.is_running())
6d47df
-    try:
6d47df
-        rpcidmapd.restart()
6d47df
-        print("Started %s" % rpcidmapd.service_name)
6d47df
-    except Exception as e:
6d47df
-        logger.error("%s failed to restart: %s", rpcidmapd.service_name, e)
6d47df
-    try:
6d47df
-        rpcidmapd.enable()
6d47df
-    except Exception as e:
6d47df
-        print("Failed to configure automatic startup of the %s daemon" % (rpcidmapd.service_name))
6d47df
-        logger.error("Failed to enable automatic startup of the %s daemon: %s",
6d47df
-                     rpcidmapd.service_name, str(e))
6d47df
-
6d47df
     rpcgssd = services.knownservices.rpcgssd
6d47df
-    statestore.backup_state('rpcgssd', 'enabled', rpcgssd.is_enabled())
6d47df
-    statestore.backup_state('rpcgssd', 'running', rpcgssd.is_running())
6d47df
     try:
6d47df
         rpcgssd.restart()
6d47df
-        print("Started %s" % rpcgssd.service_name)
6d47df
     except Exception as e:
6d47df
-        logger.error("%s failed to restart: %s", rpcgssd.service_name, e)
6d47df
+        logger.error("Failed to restart rpc-gssd (%s)" % str(e))
6d47df
+        return 1
6d47df
+    nfsutils = services.knownservices['nfs-utils']
6d47df
     try:
6d47df
-        rpcgssd.enable()
6d47df
+        nfsutils.restart()
6d47df
     except Exception as e:
6d47df
-        print("Failed to configure automatic startup of the %s daemon" % (rpcgssd.service_name))
6d47df
-        logger.error("Failed to enable automatic startup of the %s daemon: %s",
6d47df
-                     rpcgssd.service_name, str(e))
6d47df
+        logger.error("Failed to restart nfs client services (%s)" % str(e))
6d47df
+        return 1
6d47df
 
6d47df
 def main():
6d47df
     try:
6d47df
diff --git a/ipaplatform/base/services.py b/ipaplatform/base/services.py
6d47df
index 4533ad5b34..51c27848d7 100644
6d47df
--- a/ipaplatform/base/services.py
6d47df
+++ b/ipaplatform/base/services.py
6d47df
@@ -53,7 +53,8 @@
6d47df
                      'dbus', 'nslcd', 'nscd', 'ntpd', 'portmap',
6d47df
                      'rpcbind', 'kadmin', 'sshd', 'autofs', 'rpcgssd',
6d47df
                      'rpcidmapd', 'pki_tomcatd', 'chronyd', 'domainname',
6d47df
-                     'named', 'ods_enforcerd', 'ods_signerd', 'gssproxy']
6d47df
+                     'named', 'ods_enforcerd', 'ods_signerd', 'gssproxy',
6d47df
+                     'nfs-utils']
6d47df
 
6d47df
 # The common ports for these services. This is used to wait for the
6d47df
 # service to become available.
6d47df
From dfd741d3cd9c9d695e7ad6f88dcd4432fb73c126 Mon Sep 17 00:00:00 2001
6d47df
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
6d47df
Date: Mon, 10 Dec 2018 17:12:03 +0100
6d47df
Subject: [PATCH] ipatests: add a test for ipa-client-automount
6d47df
MIME-Version: 1.0
6d47df
Content-Type: text/plain; charset=UTF-8
6d47df
Content-Transfer-Encoding: 8bit
6d47df
6d47df
Add an automount location then configure a client
6d47df
to use it. Only runs nightly.
6d47df
6d47df
Related-to: https://pagure.io/freeipa/issue/7780
6d47df
Related-to: https://pagure.io/freeipa/issue/7781
6d47df
Related to: https://pagure.io/freeipa/issue/7783
6d47df
Signed-off-by: François Cami <fcami@redhat.com>
6d47df
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
6d47df
---
6d47df
 ipatests/prci_definitions/nightly_master.yaml | 12 +++
6d47df
 .../test_automount_locations.py               | 84 +++++++++++++++++++
6d47df
 2 files changed, 96 insertions(+)
6d47df
 create mode 100644 ipatests/test_integration/test_automount_locations.py
6d47df
6d47df
diff --git a/ipatests/prci_definitions/nightly_master.yaml b/ipatests/prci_definitions/nightly_master.yaml
6d47df
index 154e4c945d..b4dcc0870e 100644
6d47df
--- a/ipatests/prci_definitions/nightly_master.yaml
6d47df
+++ b/ipatests/prci_definitions/nightly_master.yaml
6d47df
@@ -663,3 +663,15 @@ jobs:
6d47df
         template: *ci-master-f29
6d47df
         timeout: 3600
6d47df
         topology: *master_1repl
6d47df
+
6d47df
+  fedora-29/test_automount_locations:
6d47df
+    requires: [fedora-29/build]
6d47df
+    priority: 50
6d47df
+    job:
6d47df
+      class: RunPytest
6d47df
+      args:
6d47df
+        build_url: '{fedora-29/build_url}'
6d47df
+        test_suite: test_integration/test_automount_locations.py
6d47df
+        template: *ci-master-f29
6d47df
+        timeout: 6300
6d47df
+        topology: *master_1repl
6d47df
diff --git a/ipatests/test_integration/test_automount_locations.py b/ipatests/test_integration/test_automount_locations.py
6d47df
new file mode 100644
6d47df
index 0000000000..646d1d07a0
6d47df
--- /dev/null
6d47df
+++ b/ipatests/test_integration/test_automount_locations.py
6d47df
@@ -0,0 +1,84 @@
6d47df
+#
6d47df
+# Copyright (C) 2018  FreeIPA Contributors see COPYING for license
6d47df
+#
6d47df
+
6d47df
+"""This module provides tests for the automount location feature.
6d47df
+"""
6d47df
+
6d47df
+from __future__ import absolute_import
6d47df
+
6d47df
+import time
6d47df
+import re
6d47df
+
6d47df
+from ipatests.test_integration.base import IntegrationTest
6d47df
+from ipatests.pytest_ipa.integration import tasks
6d47df
+
6d47df
+# give some time for units to stabilize
6d47df
+# otherwise we get transient errors
6d47df
+WAIT_AFTER_INSTALL = 5
6d47df
+WAIT_AFTER_UNINSTALL = WAIT_AFTER_INSTALL
6d47df
+
6d47df
+
6d47df
+class TestAutomountInstallUninstall(IntegrationTest):
6d47df
+    """
6d47df
+    Test if ipa-client-automount behaves as expected
6d47df
+    """
6d47df
+
6d47df
+    num_replicas = 1
6d47df
+    topology = 'star'
6d47df
+
6d47df
+    @classmethod
6d47df
+    def install(cls, mh):
6d47df
+        tasks.install_master(cls.master, setup_dns=False)
6d47df
+        client = cls.replicas[0]
6d47df
+        tasks.install_client(cls.master, client)
6d47df
+
6d47df
+    def test_use_automount_location(self):
6d47df
+
6d47df
+        client = self.replicas[0]
6d47df
+
6d47df
+        self.master.run_command([
6d47df
+            "ipa", "automountlocation-add", "baltimore"
6d47df
+        ])
6d47df
+
6d47df
+        self.master.run_command([
6d47df
+            "ipa", "host-mod", client.hostname,
6d47df
+            "--location", "baltimore"
6d47df
+        ])
6d47df
+
6d47df
+        # systemctl non-fatal errors will only be displayed
6d47df
+        # if ipa-client-automount is launched with --debug
6d47df
+        result1 = client.run_command([
6d47df
+            'ipa-client-automount', '--location', 'baltimore',
6d47df
+            '-U', '--debug'
6d47df
+        ])
6d47df
+
6d47df
+        # systemctl non-fatal errors will show up like this:
6d47df
+        # stderr=Failed to restart nfs-secure.service: \
6d47df
+        #        Unit nfs-secure.service not found.
6d47df
+        # normal output:
6d47df
+        # stderr=
6d47df
+        m1 = re.search(r'(?<=stderr\=Failed).+', result1.stderr_text)
6d47df
+        # maybe re-use m1.group(0) if it exists.
6d47df
+        assert m1 is None
6d47df
+
6d47df
+        time.sleep(WAIT_AFTER_INSTALL)
6d47df
+
6d47df
+        result2 = client.run_command([
6d47df
+            'ipa-client-automount', '--uninstall',
6d47df
+            '-U', '--debug'
6d47df
+        ])
6d47df
+
6d47df
+        m2 = re.search(r'(?<=stderr\=Failed).+', result2.stderr_text)
6d47df
+        assert m2 is None
6d47df
+
6d47df
+        time.sleep(WAIT_AFTER_UNINSTALL)
6d47df
+
6d47df
+        self.master.run_command([
6d47df
+            "ipa", "host-mod", client.hostname,
6d47df
+            "--location", "''"
6d47df
+        ])
6d47df
+
6d47df
+        self.master.run_command([
6d47df
+            "ipa", "automountlocation-del", "baltimore"
6d47df
+        ])