summaryrefslogtreecommitdiffstats
path: root/roles/openshift_health_checker/openshift_checks/etcd_traffic.py
diff options
context:
space:
mode:
authorLuke Meyer <lmeyer@redhat.com>2017-06-16 17:24:01 -0400
committerLuke Meyer <lmeyer@redhat.com>2017-07-25 13:23:58 -0400
commit210fc2d3849a1baf9c1d8535044d92df23424274 (patch)
tree20b6998ca0696257eb816e4ace464ee95b926816 /roles/openshift_health_checker/openshift_checks/etcd_traffic.py
parent2a0936b291992ba1b7343680aec915df0c29892c (diff)
downloadopenshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.gz
openshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.bz2
openshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.xz
openshift-210fc2d3849a1baf9c1d8535044d92df23424274.zip
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.
Diffstat (limited to 'roles/openshift_health_checker/openshift_checks/etcd_traffic.py')
-rw-r--r--roles/openshift_health_checker/openshift_checks/etcd_traffic.py19
1 files changed, 8 insertions, 11 deletions
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"