forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: don't double-count RAID volumes in disk metrics
Previously, we wouldn't exclude volumes from disk counters that are likely to be double-counted such as RAID logical volumes that are composed of physical volumes that are also independently present in disk metrics. This change adds a regex-based filter, overridable with env vars, that excludes common double-counted volume patterns. Fixes cockroachdb#97867. Epic: none Release note (bug fix): Avoids double-counting disk read/write bytes in disk metrics if Cockroach observes volumes that are likely to be duplicated in reported disk counters, such as RAID logical vs physical volumes.
- Loading branch information
Showing
6 changed files
with
139 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,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 "^(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, | ||
}, | ||
{ | ||
Name: "sda1", | ||
ReadBytes: 1, | ||
readCount: 1, | ||
iopsInProgress: 1, | ||
WriteBytes: 1, | ||
writeCount: 1, | ||
}, | ||
{ // This must be excluded from the sum. | ||
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