-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104806 from itsbilal/backport23.1-104640
release-23.1: server: don't double-count RAID volumes in disk metrics
- Loading branch information
Showing
6 changed files
with
145 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
//go:build !linux | ||
// +build !linux | ||
|
||
package status | ||
|
||
func getDefaultIgnoredDevices() string { | ||
return "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
//go:build linux | ||
// +build linux | ||
|
||
package status | ||
|
||
func getDefaultIgnoredDevices() string { | ||
// Excludes disks that have likely been counted elsewhere already, eg. | ||
// sda1 gets excluded because sda would count it instead, and nvme1n1p1 is | ||
// excluded as nvme1n1 is counted. | ||
// | ||
// This default regex is taken from Prometheus: | ||
// https://github.com/prometheus/node_exporter/blob/690efa61e86acefdf05bb4334a3d68128ded49c9/collector/diskstats_linux.go#L39 | ||
return "^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\\d+n\\d+p)\\d+$" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
//go:build linux | ||
// +build linux | ||
|
||
package status | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
) | ||
|
||
func TestSumAndFilterDiskCountersLinux(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
|
||
counters := []DiskStats{ | ||
{ | ||
Name: "nvme0", | ||
ReadBytes: 1, | ||
readCount: 1, | ||
iopsInProgress: 1, | ||
WriteBytes: 1, | ||
writeCount: 1, | ||
}, | ||
{ // This must be excluded from the sum. | ||
Name: "sda1", | ||
ReadBytes: 100, | ||
readCount: 100, | ||
iopsInProgress: 100, | ||
WriteBytes: 100, | ||
writeCount: 100, | ||
}, | ||
{ | ||
Name: "nvme1n1", | ||
ReadBytes: 1, | ||
readCount: 1, | ||
iopsInProgress: 1, | ||
WriteBytes: 1, | ||
writeCount: 1, | ||
}, | ||
} | ||
summed, err := sumAndFilterDiskCounters(counters) | ||
if err != nil { | ||
t.Fatalf("error: %s", err.Error()) | ||
} | ||
expected := DiskStats{ | ||
ReadBytes: 2, | ||
readCount: 2, | ||
WriteBytes: 2, | ||
writeCount: 2, | ||
iopsInProgress: 2, | ||
} | ||
if !reflect.DeepEqual(summed, expected) { | ||
t.Fatalf("expected %+v; got %+v", expected, summed) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters