mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
fingerprint: add config option to disable dmidecode (#25108)
This commit is contained in:
3
.changelog/25108.txt
Normal file
3
.changelog/25108.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:improvement
|
||||
cpustats: Add config "cpu_disable_dmidecode" to disable cpu detection using dmidecode
|
||||
```
|
||||
@@ -123,6 +123,9 @@ type Config struct {
|
||||
// be determined dynamically.
|
||||
NetworkSpeed int
|
||||
|
||||
// CpuDisableDmidecode disables cpu fingerprinting using dmidecode on Linux
|
||||
CpuDisableDmidecode bool
|
||||
|
||||
// CpuCompute is the default total CPU compute if they can not be determined
|
||||
// dynamically. It should be given as Cores * MHz (2 Cores * 2 Ghz = 4000)
|
||||
CpuCompute int
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
topology = numalib.Scan(numalib.PlatformScanners())
|
||||
topology = numalib.Scan(numalib.PlatformScanners(false))
|
||||
)
|
||||
|
||||
// TestDriverManager_Fingerprint_Run asserts that node is populated with
|
||||
|
||||
@@ -88,7 +88,7 @@ func (f *CPUFingerprint) initialize(request *FingerprintRequest) {
|
||||
}
|
||||
|
||||
f.top = numalib.Scan(append(
|
||||
numalib.PlatformScanners(),
|
||||
numalib.PlatformScanners(request.Config.CpuDisableDmidecode),
|
||||
&numalib.ConfigScanner{
|
||||
ReservableCores: reservableCores,
|
||||
ReservedCores: reservedCores,
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// PlatformScanners returns the set of SystemScanner for macOS.
|
||||
func PlatformScanners() []SystemScanner {
|
||||
func PlatformScanners(_ bool) []SystemScanner {
|
||||
return []SystemScanner{
|
||||
new(MacOS),
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ package numalib
|
||||
|
||||
// PlatformScanners returns the set of SystemScanner for systems without a
|
||||
// specific implementation.
|
||||
func PlatformScanners() []SystemScanner {
|
||||
func PlatformScanners(_ bool) []SystemScanner {
|
||||
return []SystemScanner{
|
||||
new(Generic),
|
||||
}
|
||||
|
||||
@@ -19,14 +19,16 @@ import (
|
||||
)
|
||||
|
||||
// PlatformScanners returns the set of SystemScanner for Linux.
|
||||
func PlatformScanners() []SystemScanner {
|
||||
return []SystemScanner{
|
||||
new(Sysfs),
|
||||
new(Smbios),
|
||||
new(Cgroups1),
|
||||
new(Cgroups2),
|
||||
new(Fallback),
|
||||
func PlatformScanners(cpuDisableDmidecode bool) []SystemScanner {
|
||||
scanners := []SystemScanner{new(Sysfs)}
|
||||
if !cpuDisableDmidecode {
|
||||
scanners = append(scanners, new(Smbios))
|
||||
}
|
||||
scanners = append(scanners, new(Cgroups1))
|
||||
scanners = append(scanners, new(Cgroups2))
|
||||
scanners = append(scanners, new(Fallback))
|
||||
|
||||
return scanners
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -17,7 +17,7 @@ func Test_NoImpl_yes(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_NoImpl_no(t *testing.T) {
|
||||
original := Scan(PlatformScanners())
|
||||
original := Scan(PlatformScanners(false))
|
||||
fallback := NoImpl(original)
|
||||
must.EqOp(t, original, fallback) // pointer is same
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// TestScanTopology is going to be different on every machine; even the CI
|
||||
// systems change sometimes so it's hard to make good assertions here.
|
||||
func TestScanTopology(t *testing.T) {
|
||||
top := Scan(PlatformScanners())
|
||||
top := Scan(PlatformScanners(false))
|
||||
must.Positive(t, top.UsableCompute())
|
||||
must.Positive(t, top.TotalCompute())
|
||||
must.Positive(t, top.NumCores())
|
||||
|
||||
@@ -27,7 +27,7 @@ type testManager struct {
|
||||
}
|
||||
|
||||
func TestDriverManager(t *testing.T) Manager {
|
||||
topology := numalib.Scan(numalib.PlatformScanners())
|
||||
topology := numalib.Scan(numalib.PlatformScanners(false))
|
||||
logger := testlog.HCLogger(t).Named("driver_mgr")
|
||||
pluginLoader := catalog.TestPluginLoader(t)
|
||||
return &testManager{
|
||||
|
||||
@@ -755,6 +755,9 @@ func convertClientConfig(agentConfig *Config) (*clientconfig.Config, error) {
|
||||
if agentConfig.Client.NetworkSpeed != 0 {
|
||||
conf.NetworkSpeed = agentConfig.Client.NetworkSpeed
|
||||
}
|
||||
if agentConfig.Client.CpuDisableDmidecode {
|
||||
conf.CpuDisableDmidecode = agentConfig.Client.CpuDisableDmidecode
|
||||
}
|
||||
if agentConfig.Client.CpuCompute != 0 {
|
||||
conf.CpuCompute = agentConfig.Client.CpuCompute
|
||||
}
|
||||
|
||||
@@ -275,6 +275,9 @@ type ClientConfig struct {
|
||||
// speed.
|
||||
NetworkSpeed int `hcl:"network_speed"`
|
||||
|
||||
// CpuDisableDmidecode is used to disable dmidecode usage for CPU calculation
|
||||
CpuDisableDmidecode bool `hcl:"cpu_disable_dmidecode"`
|
||||
|
||||
// CpuCompute is used to override any detected or default total CPU compute.
|
||||
CpuCompute int `hcl:"cpu_total_compute"`
|
||||
|
||||
@@ -2346,6 +2349,9 @@ func (a *ClientConfig) Merge(b *ClientConfig) *ClientConfig {
|
||||
if b.NetworkSpeed != 0 {
|
||||
result.NetworkSpeed = b.NetworkSpeed
|
||||
}
|
||||
if b.CpuDisableDmidecode {
|
||||
result.CpuDisableDmidecode = b.CpuDisableDmidecode
|
||||
}
|
||||
if b.CpuCompute != 0 {
|
||||
result.CpuCompute = b.CpuCompute
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
top = numalib.Scan(numalib.PlatformScanners())
|
||||
top = numalib.Scan(numalib.PlatformScanners(false))
|
||||
)
|
||||
|
||||
func dockerIsRemote() bool {
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
topology = numalib.Scan(numalib.PlatformScanners())
|
||||
topology = numalib.Scan(numalib.PlatformScanners(false))
|
||||
)
|
||||
|
||||
// TestDockerDriver_FingerprintHealth asserts that docker reports healthy
|
||||
|
||||
@@ -75,7 +75,7 @@ func testResources(allocID, task string) *drivers.Resources {
|
||||
}
|
||||
|
||||
func newExecDriverTest(t *testing.T, ctx context.Context) drivers.DriverPlugin {
|
||||
topology := numalib.Scan(numalib.PlatformScanners())
|
||||
topology := numalib.Scan(numalib.PlatformScanners(false))
|
||||
d := NewExecDriver(ctx, testlog.HCLogger(t))
|
||||
d.(*Driver).nomadConfig = &base.ClientDriverConfig{Topology: topology}
|
||||
d.(*Driver).userIDValidator = &mockIDValidator{}
|
||||
|
||||
@@ -39,7 +39,7 @@ func javaCompatible(t *testing.T) {
|
||||
}
|
||||
|
||||
func newJavaDriverTest(t *testing.T, ctx context.Context) drivers.DriverPlugin {
|
||||
topology := numalib.Scan(numalib.PlatformScanners())
|
||||
topology := numalib.Scan(numalib.PlatformScanners(false))
|
||||
d := NewDriver(ctx, testlog.HCLogger(t))
|
||||
d.(*Driver).nomadConfig = &base.ClientDriverConfig{Topology: topology}
|
||||
return d
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestQemuDriver_Start_Wait_Stop(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
topology := numalib.Scan(numalib.PlatformScanners())
|
||||
topology := numalib.Scan(numalib.PlatformScanners(false))
|
||||
d := NewQemuDriver(ctx, testlog.HCLogger(t))
|
||||
d.(*Driver).nomadConfig = &base.ClientDriverConfig{Topology: topology}
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
@@ -116,7 +116,7 @@ func TestQemuDriver_User(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
topology := numalib.Scan(numalib.PlatformScanners())
|
||||
topology := numalib.Scan(numalib.PlatformScanners(false))
|
||||
d := NewQemuDriver(ctx, testlog.HCLogger(t))
|
||||
d.(*Driver).nomadConfig = &base.ClientDriverConfig{Topology: topology}
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
@@ -161,7 +161,7 @@ func TestQemuDriver_Stats(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
topology := numalib.Scan(numalib.PlatformScanners())
|
||||
topology := numalib.Scan(numalib.PlatformScanners(false))
|
||||
d := NewQemuDriver(ctx, testlog.HCLogger(t))
|
||||
d.(*Driver).nomadConfig = &base.ClientDriverConfig{Topology: topology}
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
var (
|
||||
topology = numalib.Scan(numalib.PlatformScanners())
|
||||
topology = numalib.Scan(numalib.PlatformScanners(false))
|
||||
)
|
||||
|
||||
type mockIDValidator struct{}
|
||||
|
||||
@@ -55,7 +55,7 @@ func init() {
|
||||
}
|
||||
|
||||
var (
|
||||
topology = numalib.Scan(numalib.PlatformScanners())
|
||||
topology = numalib.Scan(numalib.PlatformScanners(false))
|
||||
compute = topology.Compute()
|
||||
)
|
||||
|
||||
@@ -341,7 +341,7 @@ func TestExecutor_Shutdown_Exit(t *testing.T) {
|
||||
}
|
||||
|
||||
driverCfg := &base.ClientDriverConfig{
|
||||
Topology: numalib.Scan(numalib.PlatformScanners()),
|
||||
Topology: numalib.Scan(numalib.PlatformScanners(false)),
|
||||
}
|
||||
|
||||
executor, pluginClient, err := CreateExecutor(testlog.HCLogger(t), driverCfg, cfg)
|
||||
|
||||
@@ -61,7 +61,7 @@ func testExecutorCommand(t *testing.T) *testExecCmd {
|
||||
func TestExecutor_ProcessExit(t *testing.T) {
|
||||
ci.Parallel(t)
|
||||
|
||||
topology := numalib.Scan(numalib.PlatformScanners())
|
||||
topology := numalib.Scan(numalib.PlatformScanners(false))
|
||||
compute := topology.Compute()
|
||||
|
||||
cmd := testExecutorCommand(t)
|
||||
|
||||
@@ -78,6 +78,9 @@ client {
|
||||
the preferred family. When the option is not specified, the current behavior is conserved:
|
||||
the first IP address is selected no matter the family.
|
||||
|
||||
- `cpu_disable_dmidecode` `(bool: false)` - Specifies the client should not use dmidecode
|
||||
as a method of cpu detection. Nomad ignores this field on all platforms except Linux.
|
||||
|
||||
- `cpu_total_compute` `(int: 0)` - Specifies an override for the total CPU
|
||||
compute. This value should be set to `# Cores * Core MHz`. For example, a
|
||||
quad-core running at 2 GHz would have a total compute of 8000 (4 \* 2000). Most
|
||||
|
||||
Reference in New Issue
Block a user