Hello,

Attached patches fix systemd and ipactl related bugs:

https://fedorahosted.org/freeipa/ticket/3730
https://fedorahosted.org/freeipa/ticket/3729

-- 
Regards,

Ana Krivokapic
Associate Software Engineer
FreeIPA team
Red Hat Inc.

From 772c84f2e9beb5a9654fe6ccc78159a67371a06e Mon Sep 17 00:00:00 2001
From: Ana Krivokapic <akriv...@redhat.com>
Date: Thu, 20 Jun 2013 11:53:29 +0200
Subject: [PATCH] Use correct DS instance in ipactl status

Make sure ipactl status check for correct DS instance. It should check for
'dirsrv@IPA-REALM' and not 'dirsrv.target'.

https://fedorahosted.org/freeipa/ticket/3730
---
 ipapython/platform/base/systemd.py | 20 +++++++++++++++-----
 ipaserver/install/dsinstance.py    |  2 ++
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/ipapython/platform/base/systemd.py b/ipapython/platform/base/systemd.py
index a9c1ec03261ae8694b1a308b2e86f342f27e9e62..57355e914c08a9fa4102707bb6d57cd33b8ff1f5 100644
--- a/ipapython/platform/base/systemd.py
+++ b/ipapython/platform/base/systemd.py
@@ -18,8 +18,6 @@
 #
 
 import os
-import shutil
-import sys
 
 from ipapython import ipautil
 from ipapython.platform import base
@@ -36,12 +34,18 @@ def __init__(self, service_name, systemd_name):
         self.lib_path = os.path.join(self.SYSTEMD_LIB_PATH, self.systemd_name)
         self.lib_path_exists = None
 
-    def service_instance(self, instance_name):
+    def service_instance(self, instance_name, operation=None):
         if self.lib_path_exists is None:
             self.lib_path_exists = os.path.exists(self.lib_path)
 
         elements = self.systemd_name.split("@")
 
+        # Make sure the correct DS instance is returned
+        if (elements[0] == 'dirsrv' and
+                not instance_name and
+                operation == 'is-active'):
+            return 'dirsrv@%s.service' % str(api.env.realm.replace('.', '-'))
+
         # Short-cut: if there is already exact service name, return it
         if self.lib_path_exists and len(instance_name) == 0:
             if len(elements) == 1:
@@ -119,12 +123,18 @@ def restart(self, instance_name="", capture_output=True, wait=True):
 
     def is_running(self, instance_name=""):
         ret = True
+        instance = self.service_instance(instance_name, 'is-active')
+
         try:
-            (sout, serr, rcode) = ipautil.run(["/bin/systemctl", "is-active", self.service_instance(instance_name)],capture_output=True)
+            (sout, serr, rcode) = ipautil.run(
+                ["/bin/systemctl", "is-active", instance],
+                capture_output=True
+            )
             if rcode != 0:
                 ret = False
         except ipautil.CalledProcessError:
-                ret = False
+            ret = False
+
         return ret
 
     def is_installed(self):
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
index 01b082a702be61f311d2b223085177c2fe2b85cd..34d5e2369cef97fd6345fdc40c3825ae78489186 100644
--- a/ipaserver/install/dsinstance.py
+++ b/ipaserver/install/dsinstance.py
@@ -433,6 +433,8 @@ def __add_default_schemas(self):
     def restart(self, instance=''):
         try:
             super(DsInstance, self).restart(instance)
+            # wait 2 seconds for the service to start
+            time.sleep(2)
             if not is_ds_running(instance):
                 root_logger.critical("Failed to restart the directory server. See the installation log for details.")
                 sys.exit(1)
-- 
1.8.1.4

From 0173d04a468d71f0cf6866d575d1e9aaae6df8e4 Mon Sep 17 00:00:00 2001
From: Ana Krivokapic <akriv...@redhat.com>
Date: Thu, 20 Jun 2013 17:04:49 +0200
Subject: [PATCH] Avoid systemd service deadlock during shutdown

https://fedorahosted.org/freeipa/ticket/3729
---
 init/systemd/ipa.service           |  2 +-
 ipapython/platform/base/systemd.py | 12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/init/systemd/ipa.service b/init/systemd/ipa.service
index 8cfcf7c541080cbfa5c402aba801dee901141e3d..5073e73e21d880e3fe8594454601345704cbdf53 100644
--- a/init/systemd/ipa.service
+++ b/init/systemd/ipa.service
@@ -1,7 +1,7 @@
 [Unit]
 Description=Identity, Policy, Audit
 Requires=network.target
-After=network.target
+After=network.target dirsrv.target pki-tomcatd@pki-tomcat.service pki-cad.target certmonger.service httpd.service krb5kdc.service messagebus.service nslcd.service nscd.service ntpd.service portmap.service rpcbind.service kadmin.service sshd.service autofs.service rpcgssd.service rpcidmapd.service chronyd.service
 
 [Service]
 Type=oneshot
diff --git a/ipapython/platform/base/systemd.py b/ipapython/platform/base/systemd.py
index a9c1ec03261ae8694b1a308b2e86f342f27e9e62..d9609992f6a0a205451ba2adb5b27bf05aeb363f 100644
--- a/ipapython/platform/base/systemd.py
+++ b/ipapython/platform/base/systemd.py
@@ -93,7 +93,17 @@ def __wait_for_open_ports(self, instance_name=""):
             ipautil.wait_for_open_ports('localhost', ports, api.env.startup_timeout)
 
     def stop(self, instance_name="", capture_output=True):
-        ipautil.run(["/bin/systemctl", "stop", self.service_instance(instance_name)], capture_output=capture_output)
+        instance = self.service_instance(instance_name)
+
+        # The --ignore-dependencies switch is used to avoid possible
+        # deadlock during the shutdown transaction. For more details, see
+        # https://fedorahosted.org/freeipa/ticket/3729#comment:1 and
+        # https://bugzilla.redhat.com/show_bug.cgi?id=973331#c11
+        ipautil.run(
+            ["/bin/systemctl", "stop", instance, "--ignore-dependencies"],
+            capture_output=capture_output
+        )
+
         if 'context' in api.env and api.env.context in ['ipactl', 'installer']:
             update_service_list = True
         else:
-- 
1.8.1.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to