From 576309438c43bb2ec000f84db923eaa98ab09707 Mon Sep 17 00:00:00 2001 From: John McGrath <8764013+jmcgrath207@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:31:33 -0600 Subject: [PATCH] Fix Crash if empty pods are found (#45) --- Makefile | 4 ++-- README.md | 2 +- chart/Chart.yaml | 4 ++-- chart/README.md | 2 +- chart/index.yaml | 24 +++++++++++++++++++++++- chart/values.yaml | 2 +- main.go | 2 +- 7 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index b98ed85..f9c0ac6 100644 --- a/Makefile +++ b/Makefile @@ -58,10 +58,10 @@ release-helm: cd .. release: github_login release-docker release-helm helm-docs - # ex. make VERSION=1.3.0 release + # ex. make VERSION=1.3.1 release release-github: github_login - # ex. make VERSION=1.3.0 release-github + # ex. make VERSION=1.3.1 release-github gh release create ${VERSION} --generate-notes gh release upload ${VERSION} "chart/k8s-ephemeral-storage-metrics-${VERSION}.tgz" rm chart/k8s-ephemeral-storage-metrics-*.tgz diff --git a/README.md b/README.md index 1a7d26e..b0d01b2 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ helm upgrade --install my-deployment k8s-ephemeral-storage-metrics/k8s-ephemeral | dev.enabled | bool | `false` | | | image.imagePullPolicy | string | `"IfNotPresent"` | | | image.repository | string | `"ghcr.io/jmcgrath207/k8s-ephemeral-storage-metrics"` | | -| image.tag | string | `"1.3.0"` | | +| image.tag | string | `"1.3.1"` | | | interval | int | `15` | Polling node rate for exporter | | log_level | string | `"info"` | | | max_node_concurrency | int | `10` | Max number of concurrent query requests to the kubernetes API. | diff --git a/chart/Chart.yaml b/chart/Chart.yaml index 6f7f792..2837b08 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: k8s-ephemeral-storage-metrics -version: 1.3.0 -appVersion: 1.3.0 +version: 1.3.1 +appVersion: 1.3.1 kubeVersion: ">=1.21.0-0" description: Ephemeral storage metrics for prometheus operator. home: https://github.com/jmcgrath207/k8s-ephemeral-storage-metrics diff --git a/chart/README.md b/chart/README.md index 5f446b2..aed5611 100644 --- a/chart/README.md +++ b/chart/README.md @@ -14,7 +14,7 @@ helm upgrade --install my-deployment k8s-ephemeral-storage-metrics/k8s-ephemeral | dev.enabled | bool | `false` | | | image.imagePullPolicy | string | `"IfNotPresent"` | | | image.repository | string | `"ghcr.io/jmcgrath207/k8s-ephemeral-storage-metrics"` | | -| image.tag | string | `"1.3.0"` | | +| image.tag | string | `"1.3.1"` | | | interval | int | `15` | Polling node rate for exporter | | log_level | string | `"info"` | | | max_node_concurrency | int | `10` | Max number of concurrent query requests to the kubernetes API. | diff --git a/chart/index.yaml b/chart/index.yaml index 224cdfa..69a11af 100644 --- a/chart/index.yaml +++ b/chart/index.yaml @@ -1,6 +1,28 @@ apiVersion: v1 entries: k8s-ephemeral-storage-metrics: + - annotations: + artifacthub.io/license: MIT + artifacthub.io/links: | + - name: Documentation + url: https://github.com/jmcgrath207/k8s-ephemeral-storage-metrics + artifacthub.io/prerelease: "false" + apiVersion: v2 + appVersion: 1.3.1 + created: "2023-11-27T17:18:17.453989503-06:00" + description: Ephemeral storage metrics for prometheus operator. + digest: 09b75695d953715ad8f68c4426b4c3a2bd61cb67137818ee06de6bb7d6cb48af + home: https://github.com/jmcgrath207/k8s-ephemeral-storage-metrics + keywords: + - kubernetes + - metrics + kubeVersion: '>=1.21.0-0' + name: k8s-ephemeral-storage-metrics + sources: + - https://github.com/jmcgrath207/k8s-ephemeral-storage-metrics + urls: + - https://github.com/jmcgrath207/k8s-ephemeral-storage-metrics/releases/download/1.3.1/k8s-ephemeral-storage-metrics-1.3.1.tgz + version: 1.3.1 - annotations: artifacthub.io/license: MIT artifacthub.io/links: | @@ -177,4 +199,4 @@ entries: urls: - https://github.com/jmcgrath207/k8s-ephemeral-storage-metrics/releases/download/1.0.0/k8s-ephemeral-storage-metrics-1.0.0.tgz version: 1.0.0 -generated: "2023-11-26T22:34:31.469131799-06:00" +generated: "2023-11-27T17:18:17.45365655-06:00" diff --git a/chart/values.yaml b/chart/values.yaml index 35258cc..5094a56 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -1,6 +1,6 @@ image: repository: ghcr.io/jmcgrath207/k8s-ephemeral-storage-metrics - tag: 1.3.0 + tag: 1.3.1 imagePullPolicy: IfNotPresent # -- Set metrics you want to enable diff --git a/main.go b/main.go index d52646c..b53b87b 100644 --- a/main.go +++ b/main.go @@ -213,7 +213,7 @@ func setMetrics(node string) { capacityBytes := pod.EphemeralStorage.CapacityBytes if podNamespace == "" || (usedBytes == 0 && pod.EphemeralStorage.AvailableBytes == 0 && pod.EphemeralStorage.CapacityBytes == 0) { log.Warn().Msg(fmt.Sprintf("pod %s/%s on %s has no metrics on its ephemeral storage usage", podName, podNamespace, nodeName)) - log.Warn().Msg(fmt.Sprintf("raw content %v", content)) + continue } if ephemeralStoragePodUsage {