Skip to content

Commit

Permalink
Merge pull request #2239 from ConnorJC3/nvme-fix
Browse files Browse the repository at this point in the history
Restrict NVMe Metrics to EBS CSI Managed Volumes
  • Loading branch information
k8s-ci-robot authored Nov 25, 2024
2 parents 0301ff3 + 1f45d80 commit 50f6b2e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion charts/aws-ebs-csi-driver/templates/_node.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ spec:
- --http-endpoint=0.0.0.0:3302
{{- end}}
{{- with .Values.node.kubeletPath }}
- --csi-mount-point-prefix={{ . }}
- --csi-mount-point-prefix={{ . }}/plugins/kubernetes.io/csi/ebs.csi.aws.com/
{{- end}}
{{- with .Values.node.volumeAttachLimit }}
- --volume-attach-limit={{ . }}
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/base/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
args:
- node
- --endpoint=$(CSI_ENDPOINT)
- --csi-mount-point-prefix=/var/lib/kubelet
- --csi-mount-point-prefix=/var/lib/kubelet/plugins/kubernetes.io/csi/ebs.csi.aws.com/
- --logging-format=text
- --v=2
env:
Expand Down
5 changes: 4 additions & 1 deletion pkg/metrics/nvme.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"math"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
"unsafe"
Expand Down Expand Up @@ -122,7 +123,9 @@ func NewNVMECollector(path, instanceID string) *NVMECollector {
"read_io_latency_histogram": prometheus.NewDesc("read_io_latency_histogram", "Histogram of read I/O latencies (in microseconds)", variableLabels, constLabels),
"write_io_latency_histogram": prometheus.NewDesc("write_io_latency_histogram", "Histogram of write I/O latencies (in microseconds)", variableLabels, constLabels),
},
csiMountPointPath: path,
// Clean CSI mount point path to normalize path
// Add trailing slash back that Clean prunes
csiMountPointPath: filepath.Clean(path) + "/",
instanceID: instanceID,
collectionDuration: prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "nvme_collector_duration_seconds",
Expand Down
7 changes: 4 additions & 3 deletions pkg/metrics/nvme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
)

func TestNewNVMECollector(t *testing.T) {
testPath := "/test/path"
testPath := "/test//unclean/../path"
expectedPath := "/test/path/"
testInstanceID := "test-instance-1"

collector := NewNVMECollector(testPath, testInstanceID)
Expand All @@ -36,8 +37,8 @@ func TestNewNVMECollector(t *testing.T) {
t.Fatal("NewNVMECollector returned nil")
}

if collector.csiMountPointPath != testPath {
t.Errorf("csiMountPointPath = %v, want %v", collector.csiMountPointPath, testPath)
if collector.csiMountPointPath != expectedPath {
t.Errorf("csiMountPointPath = %v, want %v", collector.csiMountPointPath, expectedPath)
}

if collector.instanceID != testInstanceID {
Expand Down

0 comments on commit 50f6b2e

Please sign in to comment.