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

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