Skip to content

Commit

Permalink
fix: match include/exclude labels from list
Browse files Browse the repository at this point in the history
Signed-off-by: djerfy <[email protected]>
  • Loading branch information
djerfy committed Jan 10, 2024
1 parent ceda038 commit 7c72a5c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
11 changes: 6 additions & 5 deletions src/modules/common/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ def matchLabels(match_labels=None, object_labels=None):

object_labels = str(object_labels).replace("{", "").replace("}", "").replace("'", "").replace(" ", "").split(",")

for label in object_labels:
key, value = label.split(":")[0], label.split(":")[1]
for separator in ["=", ":"]:
if match_labels.split(separator)[0] == key and match_labels.split(separator)[1] == value:
return True
for object_label in object_labels:
key, value = object_label.split(":")[0], object_label.split(":")[1]
for match_label in match_labels:
for separator in ["=", ":"]:
if match_label.split(separator)[0] == key and match_label.split(separator)[1] == value:
return True

return False
4 changes: 0 additions & 4 deletions src/modules/kubernetes/base/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ def kubernetesGetNodes(config=None):
nodes = []

for node in kubernetes.list_node().items:
if node.spec.taints is not None:
if "node.kubernetes.io/not-ready" in str(node.spec.taints):
continue

node_healthz = kubernetes.connect_get_node_proxy_with_path(name=node.metadata.name, path="healthz")
node_status = kubernetes.read_node_status(name=node.metadata.name)
node_pods = kubernetes.list_pod_for_all_namespaces(field_selector="spec.nodeName={}".format(node.metadata.name))
Expand Down
4 changes: 0 additions & 4 deletions src/modules/kubernetes/base/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ def kubernetesGetVolumes(config=None):
volumes = []

for node in kubernetes.list_node().items:
if node.spec.taints is not None:
if "node.kubernetes.io/not-ready" in str(node.spec.taints):
continue

node_info = kubernetes.connect_get_node_proxy_with_path(name=node.metadata.name, path="stats/summary").replace("'", "\"")
node_json = json.loads(node_info)

Expand Down

0 comments on commit 7c72a5c

Please sign in to comment.