Skip to content

Commit

Permalink
[fix]: remove unused func
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Yuan <[email protected]>
  • Loading branch information
SamYuan1990 committed Dec 14, 2024
1 parent 021b544 commit 931cec9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
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{
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) {
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{
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

0 comments on commit 931cec9

Please sign in to comment.