summaryrefslogtreecommitdiffstats
path: root/roles/openshift_health_checker/openshift_checks/logging/curator.py
blob: b27f9717286b0e0258f4ea1c9bd64028e7f5cf01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Check for an aggregated logging Curator deployment"""

from openshift_checks.logging.logging import OpenShiftCheckException, LoggingCheck


class Curator(LoggingCheck):
    """Check for an aggregated logging Curator deployment"""

    name = "curator"
    tags = ["health", "logging"]

    def run(self):
        """Check various things and gather errors. Returns: result as hash"""

        curator_pods = self.get_pods_for_component("curator")
        self.check_curator(curator_pods)
        # TODO(lmeyer): run it all again for the ops cluster

        return {}

    def check_curator(self, pods):
        """Check to see if curator is up and working. Returns: error string"""
        if not pods:
            raise OpenShiftCheckException(
                "MissingComponentPods",
                "There are no Curator pods for the logging stack,\n"
                "so nothing will prune Elasticsearch indexes.\n"
                "Is Curator correctly deployed?"
            )

        not_running = self.not_running_pods(pods)
        if len(not_running) == len(pods):
            raise OpenShiftCheckException(
                "CuratorNotRunning",
                "The Curator pod is not currently in a running state,\n"
                "so Elasticsearch indexes may increase without bound."
            )
        if len(pods) - len(not_running) > 1:
            raise OpenShiftCheckException(
                "TooManyCurators",
                "There is more than one Curator pod running. This should not normally happen.\n"
                "Although this doesn't cause any problems, you may want to investigate."
            )