Skip to content

Commit

Permalink
fix: do not probe for power-meters when disabled
Browse files Browse the repository at this point in the history
Previously, when DISABLE_POWER_METER is set, kepler would still probe
system for power-meters resulting in kepler_node_info to produce
incorrect results for components_power_source and platform_power_source.
E.g.
kepler_node_info{
  components_power_source="rapl-sysfs",
  cpu_architecture="Skylake",
  instance="kepler-latest:8888",
  job="latest",
  platform_power_source="acpi",
  source="os"
}

The commit fixes this to use the fake power-meters so that kepler_node_info
now shows
```
kepler_node_info{components_power_source="estimator",
  cpu_architecture="Skylake",
  instance="kepler-dev:8888",
  job="dev",
  platform_power_source="none",
  source="os"
}
```

Signed-off-by: Sunil Thaha <[email protected]>
  • Loading branch information
sthaha committed Aug 29, 2024
1 parent ecd5f54 commit 34d27b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pkg/sensors/components/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ var (
)

func InitPowerImpl() {
if !enabled {
klog.V(1).Infoln("System power collection is disabled, using estimate method")
powerImpl = &source.PowerEstimate{}
return
}

sysfsImpl := &source.PowerSysfs{}
if sysfsImpl.IsSystemCollectionSupported() /*&& false*/ {
klog.V(1).Infoln("use sysfs to obtain power")
Expand Down
10 changes: 8 additions & 2 deletions pkg/sensors/platform/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ type powerInterface interface {
}

// dummy satisfies the powerInterface and can be used as the default NOP source
type dummy struct {
}
type dummy struct{}

func (dummy) GetName() string {
return "none"
Expand All @@ -47,6 +46,7 @@ func (dummy) GetName() string {
func (dummy) IsSystemCollectionSupported() bool {
return false
}

func (dummy) StopPower() {
}

Expand All @@ -60,6 +60,12 @@ var (
)

func InitPowerImpl() {
if !enabled {
klog.V(1).Infoln("System power collection is disabled, using dummy method")
powerImpl = &dummy{}
return
}

// switch the platform power collector source to hmc if the system architecture is s390x
// TODO: add redfish or ipmi as well.
if runtime.GOARCH == "s390x" {
Expand Down

0 comments on commit 34d27b8

Please sign in to comment.