Skip to content

Commit

Permalink
Merge pull request #1810 from rootfs/idle-option
Browse files Browse the repository at this point in the history
feat(metrics): refactor idle power exposure
  • Loading branch information
sthaha authored Oct 17, 2024
2 parents 91c8e62 + 26de449 commit 3c5beae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func newAppConfig() *AppConfig {
flag.StringVar(&_config.Kubeconfig, "kubeconfig", "", "absolute path to the kubeconfig file, if empty we use the in-cluster configuration")
flag.BoolVar(&_config.ApiserverEnabled, "apiserver", true, "if apiserver is disabled, we collect pod information from kubelet")
flag.StringVar(&_config.RedfishCredFilePath, "redfish-cred-file-path", "", "path to the redfish credential file")
flag.BoolVar(&_config.ExposeEstimatedIdlePower, "expose-estimated-idle-power", false, "estimated idle power is meaningful only if Kepler is running on bare-metal or when there is only one virtual machine on the node")
flag.BoolVar(&_config.ExposeEstimatedIdlePower, "expose-estimated-idle-power", false, "Whether to expose the estimated idle power as a metric")
flag.StringVar(&_config.MachineSpecFilePath, "machine-spec", "", "path to the machine spec file in json format")
flag.BoolVar(&_config.DisablePowerMeter, "disable-power-meter", false, "whether manually disable power meter read and forcefully apply the estimator for node powers")

Expand Down Expand Up @@ -125,7 +125,7 @@ func main() {
config.SetEnabledHardwareCounterMetrics(appConfig.ExposeHardwareCounterMetrics)
config.SetEnabledGPU(appConfig.EnableGPU)
config.SetEnabledMSR(appConfig.EnableMSR)
config.SetEnabledIdlePower(appConfig.ExposeEstimatedIdlePower || components.IsSystemCollectionSupported())
config.SetEnabledIdlePower(appConfig.ExposeEstimatedIdlePower)

config.SetKubeConfig(appConfig.Kubeconfig)
config.SetEnableAPIServer(appConfig.ApiserverEnabled)
Expand Down
4 changes: 3 additions & 1 deletion pkg/collector/energy/node_energy_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ func UpdateNodeEnergyMetrics(nodeStats *stats.NodeStats) {
// update platform power later to avoid race condition when using estimation power model
UpdatePlatformEnergy(nodeStats)
// after updating the total energy we calculate the idle, dynamic and other components energy
UpdateNodeIdleEnergy(nodeStats)
if config.IsIdlePowerEnabled() {
UpdateNodeIdleEnergy(nodeStats)
}
nodeStats.UpdateDynEnergy()
nodeStats.SetNodeOtherComponentsEnergy()
}
2 changes: 1 addition & 1 deletion pkg/collector/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (s *Stats) CalcDynEnergy(absM, idleM, dynM, id string) {

// calcDynEnergy calculates the dynamic energy.
func calcDynEnergy(totalE, idleE uint64) uint64 {
if (totalE == 0) || (idleE == 0) || (totalE < idleE) {
if (totalE == 0) || (totalE < idleE) {
return 0
}
return totalE - idleE
Expand Down

0 comments on commit 3c5beae

Please sign in to comment.