Skip to content

Commit

Permalink
fix code about watermark of cpu usage percent
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiyuechen committed Oct 8, 2022
1 parent 7ef2bdf commit b255ffb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/ensurance/collector/cadvisor/cadvisor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ func (c *CadvisorCollector) Collect() (map[string][]common.TimeSeries, error) {
extResMemUse += float64(v.Stats[0].Memory.WorkingSet)
}

var containerLabels = GetContainerLabels(pod, containerId, containerName, hasExtCpuRes)
hasExtRes := hasExtCpuRes || hasExtMemRes
var containerLabels = GetContainerLabels(pod, containerId, containerName, hasExtRes)
addSampleToStateMap(types.MetricNameContainerMemTotalUsage, composeSample(containerLabels, float64(v.Stats[0].Memory.WorkingSet), now), stateMap)
klog.V(6).Infof("Pod: %s, containerName: %s, key %s, container_mem_total_usage %#v", klog.KObj(pod), containerName, key, float64(v.Stats[0].Memory.WorkingSet))

Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ func GetContainerNameFromPod(pod *v1.Pod, containerId string) string {
if len(strList) > 0 {
klog.V(6).Infof("cri-containerd is %s ", "cri-containerd-"+strList[len(strList)-1]+".scope")
klog.V(6).Infof("containerid is %s", containerId)
if "cri-containerd-"+strList[len(strList)-1]+".scope" == containerId {
klog.V(6).Infof("111111111")
containerIdFromPod := fmt.Sprintf("cri-containerd-%s.scope", strList[len(strList)-1])
if containerIdFromPod == containerId {
return v.Name
}
}
Expand Down

0 comments on commit b255ffb

Please sign in to comment.