Module: check_mk
Branch: master
Commit: 10ca8c66f0feafe51beb468c179077da4d54f87a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=10ca8c66f0feaf…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Tue Mar 26 18:40:35 2019 +0100
7070 FIX agent_kubernetes: don't output node with name "None"
If pods cannot be scheduled their assigned node is "None".
The special agent produced piggyback data for this "None"
node. This output is now removed.
Change-Id: Ic9f4545e43c8e2a6b3b96a2b22d2097083c88e75
---
.werks/7070 | 12 ++++++++++++
cmk/special_agents/agent_kubernetes.py | 13 ++++++++++---
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/.werks/7070 b/.werks/7070
new file mode 100644
index 0000000..fe734cf
--- /dev/null
+++ b/.werks/7070
@@ -0,0 +1,12 @@
+Title: agent_kubernetes: don't output node with name "None"
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1553622124
+Class: fix
+
+If pods cannot be scheduled their assigned node is "None".
+The special agent produced piggyback data for this "None"
+node. This output is now removed.
diff --git a/cmk/special_agents/agent_kubernetes.py
b/cmk/special_agents/agent_kubernetes.py
index ac250ac..20eb247 100644
--- a/cmk/special_agents/agent_kubernetes.py
+++ b/cmk/special_agents/agent_kubernetes.py
@@ -473,7 +473,13 @@ class PodList(ListLike[Pod]):
# type: () -> Dict[str, Dict[str, Dict[str, int]]]
pods_sorted = sorted(self, key=lambda pod: pod.node)
by_node = itertools.groupby(pods_sorted, lambda pod: pod.node)
- return {node: {'requests': {'pods': len(list(pods))}} for node,
pods in by_node}
+ return {
+ node: {
+ 'requests': {
+ 'pods': len(list(pods))
+ }
+ } for node, pods in by_node if node is not None
+ }
def pods_in_cluster(self):
return {'requests': {'pods': len(self)}}
@@ -496,8 +502,9 @@ class PodList(ListLike[Pod]):
by_node = itertools.groupby(pods_sorted, lambda pod: pod.node)
merge = functools.partial(left_join_dicts, operation=operator.add)
return {
- node: reduce(merge, [p.resources for p in pods
- ], Pod.zero_resources()) for node, pods in by_node
+ node: reduce(merge, [p.resources for p in pods], Pod.zero_resources())
+ for node, pods in by_node
+ if node is not None
}
def cluster_resources(self):