diff --git a/pkg/cmd/app.go b/pkg/cmd/app.go index 7255f9f2..31c582b3 100644 --- a/pkg/cmd/app.go +++ b/pkg/cmd/app.go @@ -20,9 +20,9 @@ import ( ) const ( - FlexKey = "f" // Monitor all GPUs if MIG is disabled or all GPU instances if MIG is enabled - MajorKey = "g" // Monitor top-level entities: GPUs or NvSwitches or CPUs - MinorKey = "i" // Monitor sub-level entities: GPU instances/NvLinks/CPUCores - GPUI cannot be specified if MIG is disabled + FlexKey = "f" // Monitor all GPUs if MIG is disabled or all GPU instances if MIG is enabled + MajorKey = "g" // Monitor top-level entities: GPUs or NvSwitches or CPUs + MinorKey = "i" // Monitor sub-level entities: GPU instances/NvLinks/CPUCores - GPUI cannot be specified if MIG is disabled undefinedConfigMapData = "none" deviceUsageTemplate = `Specify which devices dcgm-exporter monitors. Possible values: {{.FlexKey}} or @@ -55,7 +55,7 @@ var ( CLIRemoteHEInfo = "remote-hostengine-info" CLIGPUDevices = "devices" CLISwitchDevices = "switch-devices" - CLICpuDevices = "cpu-devices" + CLICpuDevices = "cpu-devices" CLINoHostname = "no-hostname" CLIUseFakeGpus = "fake-gpus" CLIConfigMapData = "configmap-data" @@ -113,13 +113,13 @@ func NewApp(buildVersion ...string) *cli.App { Usage: "Use old 1.x namespace", EnvVars: []string{"DCGM_EXPORTER_USE_OLD_NAMESPACE"}, }, - &cli.StringFlag{ - Name: CLICpuDevices, - Aliases: []string{"p"}, - Value: FlexKey, - Usage: DeviceUsageStr, - EnvVars: []string{"DCGM_EXPORTER_CPU_DEVICES_STR"}, - }, + &cli.StringFlag{ + Name: CLICpuDevices, + Aliases: []string{"p"}, + Value: FlexKey, + Usage: DeviceUsageStr, + EnvVars: []string{"DCGM_EXPORTER_CPU_DEVICES_STR"}, + }, &cli.StringFlag{ Name: CLIConfigMapData, Aliases: []string{"m"}, @@ -352,10 +352,10 @@ func contextToConfig(c *cli.Context) (*dcgmexporter.Config, error) { return nil, err } - cOpt, err := parseDeviceOptions(c.String(CLICpuDevices)) - if err != nil { - return nil, err - } + cOpt, err := parseDeviceOptions(c.String(CLICpuDevices)) + if err != nil { + return nil, err + } return &dcgmexporter.Config{ CollectorsFile: c.String(CLIFieldsFile), @@ -369,7 +369,7 @@ func contextToConfig(c *cli.Context) (*dcgmexporter.Config, error) { RemoteHEInfo: c.String(CLIRemoteHEInfo), GPUDevices: gOpt, SwitchDevices: sOpt, - CpuDevices: cOpt, + CpuDevices: cOpt, NoHostname: c.Bool(CLINoHostname), UseFakeGpus: c.Bool(CLIUseFakeGpus), ConfigMapData: c.String(CLIConfigMapData), diff --git a/pkg/dcgmexporter/gpu_collector_test.go b/pkg/dcgmexporter/gpu_collector_test.go index 0c18770b..18e1628b 100644 --- a/pkg/dcgmexporter/gpu_collector_test.go +++ b/pkg/dcgmexporter/gpu_collector_test.go @@ -94,16 +94,15 @@ func testDCGMGPUCollector(t *testing.T, counters []Counter) (*DCGMCollector, fun return nil } - dcgmGetCpuHierarchy = func () (dcgm.CpuHierarchy_v1, error) { - + dcgmGetCpuHierarchy = func() (dcgm.CpuHierarchy_v1, error) { Cpu := dcgm.CpuHierarchyCpu_v1{ - CpuId: 0, + CpuId: 0, OwnedCores: []uint64{0}, } hierarchy := dcgm.CpuHierarchy_v1{ Version: 0, NumCpus: 1, - Cpus: [dcgm.MAX_NUM_CPUS]dcgm.CpuHierarchyCpu_v1{Cpu}, + Cpus: [dcgm.MAX_NUM_CPUS]dcgm.CpuHierarchyCpu_v1{Cpu}, } return hierarchy, nil @@ -162,9 +161,9 @@ func testDCGMCpuCollector(t *testing.T, counters []Counter) (*DCGMCollector, fun dcgmGetDeviceInfo = func(gpuId uint) (dcgm.Device, error) { dev := dcgm.Device{ - GPU: 0, + GPU: 0, DCGMSupported: "No", - UUID: fmt.Sprintf("fake%d", gpuId), + UUID: fmt.Sprintf("fake%d", gpuId), } return dev, nil @@ -181,16 +180,15 @@ func testDCGMCpuCollector(t *testing.T, counters []Counter) (*DCGMCollector, fun return nil } - dcgmGetCpuHierarchy = func () (dcgm.CpuHierarchy_v1, error) { - + dcgmGetCpuHierarchy = func() (dcgm.CpuHierarchy_v1, error) { Cpu := dcgm.CpuHierarchyCpu_v1{ - CpuId: 0, + CpuId: 0, OwnedCores: []uint64{0, 1}, } hierarchy := dcgm.CpuHierarchy_v1{ Version: 0, NumCpus: 1, - Cpus: [dcgm.MAX_NUM_CPUS]dcgm.CpuHierarchyCpu_v1{Cpu}, + Cpus: [dcgm.MAX_NUM_CPUS]dcgm.CpuHierarchyCpu_v1{Cpu}, } return hierarchy, nil