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

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