Skip to content

Commit

Permalink
fix: labels items parser
Browse files Browse the repository at this point in the history
Signed-off-by: djerfy <[email protected]>
  • Loading branch information
djerfy committed Jan 11, 2024
1 parent f8f9881 commit 51ccf6c
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions src/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output:
level: DEBUG
level: INFO

kubernetes:
name: localhost
Expand All @@ -19,27 +19,27 @@ monitoring:
include: []
exclude: []
daemonsets:
enabled: True
enabled: False
labels:
include: []
exclude: []
volumes:
enabled: True
enabled: False
labels:
include: []
exclude: []
deployments:
enabled: True
enabled: False
labels:
include: []
exclude: []
statefulsets:
enabled: True
enabled: False
labels:
include: []
exclude: []
cronjobs:
enabled: True
enabled: False
labels:
include: []
exclude: []
Expand Down
4 changes: 2 additions & 2 deletions src/modules/kubernetes/base/cronjobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def kubernetesGetCronjobs(config):
}
}

if cronjob.metadata:
if cronjob.metadata.labels:
if hasattr(cronjob, 'metadata'):
if hasattr(cronjob.metadata, 'labels'):
if matchLabels(config['monitoring']['cronjobs']['labels']['exclude'], cronjob.metadata.labels):
continue
if config['monitoring']['cronjobs']['labels']['include'] != []:
Expand Down
4 changes: 2 additions & 2 deletions src/modules/kubernetes/base/daemonsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def kubernetesGetDaemonsets(config):
if json['replicas'][i] is None:
json['replicas'][i] = 0

if daemonset.metadata:
if daemonset.metadata.labels:
if hasattr(daemonset, 'metadata'):
if hasattr(daemonset.metadata, 'labels'):
if matchLabels(config['monitoring']['daemonsets']['labels']['exclude'], daemonset.metadata.labels):
continue
if config['monitoring']['daemonsets']['labels']['include'] != []:
Expand Down
4 changes: 2 additions & 2 deletions src/modules/kubernetes/base/deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def kubernetesGetDeployments(config):
}
}

if deployment.metadata:
if deployment.metadata.labels:
if hasattr(deployment, 'metadata'):
if hasattr(deployment.metadata, 'labels'):
if matchLabels(config['monitoring']['deployments']['labels']['exclude'], deployment.metadata.labels):
continue
if config['monitoring']['deployments']['labels']['include'] != []:
Expand Down
4 changes: 2 additions & 2 deletions src/modules/kubernetes/base/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def kubernetesGetNodes(config):
}
}

if node.metadata:
if node.metadata.labels:
if hasattr(node, 'metadata'):
if hasattr(node.metadata, 'labels'):
if matchLabels(config['monitoring']['nodes']['labels']['exclude'], node.metadata.labels):
continue
if config['monitoring']['nodes']['labels']['include'] != []:
Expand Down
4 changes: 2 additions & 2 deletions src/modules/kubernetes/base/statefulsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def kubernetesGetStatefulsets(config):
}
}

if statefulset.metadata:
if statefulset.metadata.labels:
if hasattr(statefulset, 'metadata'):
if hasattr(statefulset.metadata, 'labels'):
if matchLabels(config['monitoring']['statefulsets']['labels']['exclude'], statefulset.metadata.labels):
continue
if config['monitoring']['statefulsets']['labels']['include'] != []:
Expand Down
4 changes: 2 additions & 2 deletions src/modules/kubernetes/base/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def kubernetesGetVolumes(config):
volume['namespace'] = volume['pvcRef']['namespace']
volume['name'] = volume['pvcRef']['name']

if volume.metadata:
if volume.metadata.labels:
if hasattr(volume, 'metadata'):
if hasattr(volume.metadata, 'labels'):
if matchLabels(config['monitoring']['volumes']['labels']['exclude'], volume.metadata.labels):
continue
if config['monitoring']['volumes']['labels']['include'] != []:
Expand Down
2 changes: 1 addition & 1 deletion src/modules/kubernetes/openebs/cstorpoolclusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def openebsGetCstorpoolclusters(config):

cstorpoolclusters = []

if config['engine'] != "cstor":
if config['monitoring']['openebs']['engine'] != "cstor":
return cstorpoolclusters

for cstorpoolcluster in rawObjects(kubernetes.list_cluster_custom_object(group="cstor.openebs.io", version="v1", plural="cstorpoolclusters")):
Expand Down
2 changes: 1 addition & 1 deletion src/modules/kubernetes/openebs/cstorpoolinstances.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def openebsGetCstorpoolinstances(config):

cstorpoolinstances = []

if config['engine'] != "cstor":
if config['monitoring']['openebs']['engine'] != "cstor":
return cstorpoolinstances

for cstorpoolinstance in rawObjects(kubernetes.list_cluster_custom_object(group="cstor.openebs.io", version="v1", plural="cstorpoolinstances")):
Expand Down

0 comments on commit 51ccf6c

Please sign in to comment.