Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix]: remove unused func #1895

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions pkg/collector/metric_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package collector

import (
"os"
"sync"
"syscall"
"time"

Expand Down Expand Up @@ -63,15 +62,15 @@ type Collector struct {

func NewCollector(bpfExporter bpf.Exporter) *Collector {
bpfSupportedMetrics := bpfExporter.SupportedMetrics()
c := &Collector{
c := Collector{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NodeStats: *stats.NewNodeStats(),
ContainerStats: map[string]*stats.ContainerStats{},
ProcessStats: map[uint64]*stats.ProcessStats{},
VMStats: map[string]*stats.VMStats{},
bpfExporter: bpfExporter,
bpfSupportedMetrics: bpfSupportedMetrics,
}
return c
return &c
}

func (c *Collector) Initialize() error {
Expand Down Expand Up @@ -139,22 +138,12 @@ func (c *Collector) UpdateProcessEnergyUtilizationMetrics() {
}

func (c *Collector) updateResourceUtilizationMetrics() {
wg := &sync.WaitGroup{}
wg.Add(2)
go c.updateNodeResourceUtilizationMetrics(wg)
go c.updateProcessResourceUtilizationMetrics(wg)
wg.Wait()
c.updateProcessResourceUtilizationMetrics()
// aggregate processes' resource utilization metrics to containers, virtual machines and nodes
c.AggregateProcessResourceUtilizationMetrics()
}

// update the node metrics that are not related to aggregated resource utilization of processes
func (c *Collector) updateNodeResourceUtilizationMetrics(wg *sync.WaitGroup) {
Copy link
Collaborator

@sunya-ch sunya-ch Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep this for TODO list when we have metrics those are not related to aggregated resource utilization of processes. @rootfs. Do you recall who introduce this function?
Note that, I have no objection on removing this.

wg.Done()
}

func (c *Collector) updateProcessResourceUtilizationMetrics(wg *sync.WaitGroup) {
defer wg.Done()
func (c *Collector) updateProcessResourceUtilizationMetrics() {
// update process metrics regarding the resource utilization to be used to calculate the energy consumption
// we first updates the bpf which is responsible to include new processes in the ProcessStats collection
resourceBpf.UpdateProcessBPFMetrics(c.bpfExporter, c.ProcessStats)
Expand Down
6 changes: 3 additions & 3 deletions pkg/kubernetes/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ func newK8sClient() *kubernetes.Clientset {
}

func NewObjListWatcher(bpfSupportedMetrics bpf.SupportedMetrics) (*ObjListWatcher, error) {
w := &ObjListWatcher{
w := ObjListWatcher{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stopChannel: make(chan struct{}),
k8sCli: newK8sClient(),
ResourceKind: podResourceType,
bpfSupportedMetrics: bpfSupportedMetrics,
workqueue: workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()),
}
if w.k8sCli == nil || !config.IsAPIServerEnabled() {
return w, nil
return &w, nil
}
optionsModifier := func(options *metav1.ListOptions) {
options.FieldSelector = fields.Set{"spec.nodeName": node.Name()}.AsSelector().String() // to filter events per node
Expand Down Expand Up @@ -150,7 +150,7 @@ func NewObjListWatcher(bpfSupportedMetrics bpf.SupportedMetrics) (*ObjListWatche
return nil, err
}
IsWatcherEnabled = true
return w, nil
return &w, nil
}

func (w *ObjListWatcher) processNextItem() bool {
Expand Down
Loading