From 210fc2d3849a1baf9c1d8535044d92df23424274 Mon Sep 17 00:00:00 2001 From: Luke Meyer Date: Fri, 16 Jun 2017 17:24:01 -0400 Subject: openshift_checks: refactor to internalize task_vars Move task_vars into instance variable so we don't have to pass it around everywhere. Also store tmp. Make sure both are filled in on execute_module. In the process, is_active became an instance method, and task_vars is basically never used directly outside of test code. --- .../openshift_checks/etcd_traffic.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'roles/openshift_health_checker/openshift_checks/etcd_traffic.py') diff --git a/roles/openshift_health_checker/openshift_checks/etcd_traffic.py b/roles/openshift_health_checker/openshift_checks/etcd_traffic.py index 40c87873d..cc1b14d8a 100644 --- a/roles/openshift_health_checker/openshift_checks/etcd_traffic.py +++ b/roles/openshift_health_checker/openshift_checks/etcd_traffic.py @@ -1,6 +1,6 @@ """Check that scans journalctl for messages caused as a symptom of increased etcd traffic.""" -from openshift_checks import OpenShiftCheck, get_var +from openshift_checks import OpenShiftCheck class EtcdTraffic(OpenShiftCheck): @@ -9,19 +9,18 @@ class EtcdTraffic(OpenShiftCheck): name = "etcd_traffic" tags = ["health", "etcd"] - @classmethod - def is_active(cls, task_vars): + def is_active(self): """Skip hosts that do not have etcd in their group names.""" - group_names = get_var(task_vars, "group_names", default=[]) + group_names = self.get_var("group_names", default=[]) valid_group_names = "etcd" in group_names - version = get_var(task_vars, "openshift", "common", "short_version") + version = self.get_var("openshift", "common", "short_version") valid_version = version in ("3.4", "3.5", "1.4", "1.5") - return super(EtcdTraffic, cls).is_active(task_vars) and valid_group_names and valid_version + return super(EtcdTraffic, self).is_active() and valid_group_names and valid_version - def run(self, tmp, task_vars): - is_containerized = get_var(task_vars, "openshift", "common", "is_containerized") + def run(self): + is_containerized = self.get_var("openshift", "common", "is_containerized") unit = "etcd_container" if is_containerized else "etcd" log_matchers = [{ @@ -30,9 +29,7 @@ class EtcdTraffic(OpenShiftCheck): "unit": unit }] - match = self.execute_module("search_journalctl", { - "log_matchers": log_matchers, - }, task_vars) + match = self.execute_module("search_journalctl", {"log_matchers": log_matchers}) if match.get("matched"): msg = ("Higher than normal etcd traffic detected.\n" -- cgit v1.2.3