From dbf49d18fa6d664b1d1f0ec74a140ddacb1c48ab Mon Sep 17 00:00:00 2001 From: Sunyanan Choochotkaew Date: Tue, 11 Jul 2023 16:53:59 +0900 Subject: [PATCH] fix bugs --- pkg/bpfassets/attacher/bcc_attacher.go | 5 +++-- pkg/bpfassets/attacher/bpf_perf.go | 2 +- pkg/collector/container_hc_collector.go | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/bpfassets/attacher/bcc_attacher.go b/pkg/bpfassets/attacher/bcc_attacher.go index f5e12c4fd4..ce58466da2 100644 --- a/pkg/bpfassets/attacher/bcc_attacher.go +++ b/pkg/bpfassets/attacher/bcc_attacher.go @@ -226,7 +226,7 @@ func bccCollectProcess() (processesData []ProcessBPFMetrics, err error) { } // if ebpf map batch get operation is not supported we iterate over the map if !ebpfBatchGet { - for it := c.bpfHCMeter.Table.Iter(); it.Next(); { + for it := bccModule.Table.Iter(); it.Next(); { key := it.Key() value := it.Leaf() keys = append(keys, key) @@ -252,8 +252,9 @@ func bccCollectProcess() (processesData []ProcessBPFMetrics, err error) { keysToDelete = append(keysToDelete, key) } else { err = bccModule.Table.Delete(key) // deleting the element to reset the counter values - if err != nil && !os.IsNotExist(err) { + if err != nil { klog.Infof("could not delete bpf table elements, err: %v", err) + keysToDelete = append(keysToDelete, key) } } } diff --git a/pkg/bpfassets/attacher/bpf_perf.go b/pkg/bpfassets/attacher/bpf_perf.go index b43bb60b1c..6e51caff82 100644 --- a/pkg/bpfassets/attacher/bpf_perf.go +++ b/pkg/bpfassets/attacher/bpf_perf.go @@ -60,7 +60,7 @@ type ProcessBPFMetrics struct { CPUCycles uint64 CPUInstr uint64 CacheMisses uint64 - VecNR [config.MaxIRQ]uint16 // irq counter, 10 is the max number of irq vectors + VecNR [10]uint16 // irq counter, 10 is the max number of irq vectors Command [16]byte } diff --git a/pkg/collector/container_hc_collector.go b/pkg/collector/container_hc_collector.go index 4eca6c78be..f7f0c9076d 100644 --- a/pkg/collector/container_hc_collector.go +++ b/pkg/collector/container_hc_collector.go @@ -109,6 +109,7 @@ func (c *Collector) updateBPFMetrics() { // System process is the aggregation of all background process running outside kubernetes // this means that the list of process might be very large, so we will not add this information to the cache if !isSystemProcess { + klog.V(1).Infof("Command: %s (original:%s)", comm, ct.Command) c.ContainersMetrics[containerID].SetLatestProcess(ct.CGroupID, ct.PID, comm) } else if config.EnableProcessMetrics { c.createProcessMetricsIfNotExist(ct.PID, comm)