Module: check_mk
Branch: master
Commit: cc3fe3ffed83f114d24ab1001ba6782c932b3514
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cc3fe3ffed83f1…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Wed Mar 6 08:41:05 2019 +0100
Allow "null" rules in ClusterRoles in the k8s client
In some OpenShift installations several ClusterRoles with a value
of "null" for the rules are created. This is not allowed by the
official Kubernetes API, but we have to handle it here to be
able to monitor such installations.
CMK-1738
Change-Id: I275769560c0fa968cfd8f3fa9fd2235ecfdda4bc
---
.../0020-kubernetes-allow-empty-rules-in-clusterrole.dif | 11 +++++++++++
.../cmk/special_agents/test_agent_kubernetes.py | 14 ++++++++++++++
2 files changed, 25 insertions(+)
diff --git
a/omd/packages/python-modules/patches/0020-kubernetes-allow-empty-rules-in-clusterrole.dif
b/omd/packages/python-modules/patches/0020-kubernetes-allow-empty-rules-in-clusterrole.dif
new file mode 100644
index 0000000..cc74786
--- /dev/null
+++
b/omd/packages/python-modules/patches/0020-kubernetes-allow-empty-rules-in-clusterrole.dif
@@ -0,0 +1,11 @@
+--- dest/kubernetes-8.0.0.orig/kubernetes/client/models/v1_cluster_role.py
++++ dest/kubernetes-8.0.0/kubernetes/client/models/v1_cluster_role.py
+@@ -181,7 +181,7 @@ class V1ClusterRole(object):
+ :type: list[V1PolicyRule]
+ """
+ if rules is None:
+- raise ValueError("Invalid value for `rules`, must not be `None`")
++ rules = []
+
+ self._rules = rules
+
diff --git a/tests/integration/cmk/special_agents/test_agent_kubernetes.py
b/tests/integration/cmk/special_agents/test_agent_kubernetes.py
new file mode 100644
index 0000000..84ebdd6
--- /dev/null
+++ b/tests/integration/cmk/special_agents/test_agent_kubernetes.py
@@ -0,0 +1,14 @@
+import pytest
+
+from kubernetes.client.models import V1ClusterRole
+
+
+def test_v1_clusterrole_without_rules():
+ try:
+ role = V1ClusterRole(rules=None)
+ except ValueError:
+ pytest.fail(
+ "It must be possible to instantiate a V1ClusterRole without explicit
roles. "
+ "This is assured by patch
0020-kubernetes-allow-empty-rules-in-clusterrole.dif.")
+
+ assert role.rules == []