Blame SOURCES/0013-Add-service-check-dependencies.patch

151c79
From 235198b41a0932a7a190124fff5f8c1afa5d6679 Mon Sep 17 00:00:00 2001
151c79
From: Rob Crittenden <rcritten@redhat.com>
151c79
Date: Wed, 5 May 2021 15:35:19 -0400
151c79
Subject: [PATCH] Add service check dependencies
151c79
151c79
Since 389-ds is the heart of IPA there may not be a point in checking
151c79
all dependent services. ipa-dnskeysyncd in particular doesn't like
151c79
when it can't connect and tries to restart itself multiple times.
151c79
151c79
Note that this currently works because the services are sorted
151c79
alphabetically and dirsrv appears near the top. Re-ordering may be
151c79
necessary in the future.
151c79
151c79
I'm choosing not to add dirsrv to the other services because they
151c79
return cleanly if it is not available.
151c79
151c79
https://bugzilla.redhat.com/show_bug.cgi?id=1776687
151c79
151c79
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
151c79
---
151c79
 src/ipahealthcheck/core/core.py     | 20 ++++++++++++++++++++
151c79
 src/ipahealthcheck/meta/services.py |  2 ++
151c79
 2 files changed, 22 insertions(+)
151c79
151c79
diff --git a/src/ipahealthcheck/core/core.py b/src/ipahealthcheck/core/core.py
151c79
index a4af690..eaa2d9c 100644
151c79
--- a/src/ipahealthcheck/core/core.py
151c79
+++ b/src/ipahealthcheck/core/core.py
151c79
@@ -81,6 +81,26 @@ def run_service_plugins(plugins, source, check):
151c79
         if not isinstance(plugin, ServiceCheck):
151c79
             continue
151c79
 
151c79
+        # Try to save some time to not check dependent services if the
151c79
+        # parent is down.
151c79
+        if not set(plugin.requires).issubset(available):
151c79
+            # A required service is not available. Either it hasn't been
151c79
+            # checked yet or it isn't running. If not running break.
151c79
+            running = True
151c79
+            for result in results.results:
151c79
+                if result.check in plugin.requires:
151c79
+                    # if not in available but in results the service failed
151c79
+                    running = False
151c79
+                    break
151c79
+            if not running:
151c79
+                logger.debug(
151c79
+                    'Skipping %s:%s because %s service(s) not running',
151c79
+                    plugin.__class__.__module__,
151c79
+                    plugin.__class__.__name__,
151c79
+                    ', '.join(set(plugin.requires) - set(available))
151c79
+                )
151c79
+                continue
151c79
+
151c79
         logger.debug('Calling check %s', plugin)
151c79
         for result in plugin.check():
151c79
             # always run the service checks so dependencies work
151c79
diff --git a/src/ipahealthcheck/meta/services.py b/src/ipahealthcheck/meta/services.py
151c79
index a987108..5d80728 100644
151c79
--- a/src/ipahealthcheck/meta/services.py
151c79
+++ b/src/ipahealthcheck/meta/services.py
151c79
@@ -92,6 +92,8 @@ class ipa_dnskeysyncd(IPAServiceCheck):
151c79
     def check(self):
151c79
         self.service_name = 'ipa-dnskeysyncd'
151c79
 
151c79
+        requires = ('dirsrv',)
151c79
+
151c79
         if not bindinstance.named_conf_exists():
151c79
             return ()
151c79
 
151c79
-- 
151c79
2.31.1
151c79