|
@@ -77,16 +77,24 @@ func (cm *CostModel) buildPodMap(window opencost.Window, podMap map[podKey]*pod,
|
|
|
// so filter out the non-containing results so we don't duplicate pods. This is due to the
|
|
// so filter out the non-containing results so we don't duplicate pods. This is due to the
|
|
|
// default setup of Kubecost having replicated kube_pod_container_status_running and
|
|
// default setup of Kubecost having replicated kube_pod_container_status_running and
|
|
|
// included KSM kube_pod_container_status_running. Querying w/ UID will return both.
|
|
// included KSM kube_pod_container_status_running. Querying w/ UID will return both.
|
|
|
|
|
+ preFilterCount := len(resPods)
|
|
|
if ingestPodUID {
|
|
if ingestPodUID {
|
|
|
var resPodsUID []*source.PodsResult
|
|
var resPodsUID []*source.PodsResult
|
|
|
|
|
+ var droppedNoUID []string
|
|
|
|
|
|
|
|
for _, res := range resPods {
|
|
for _, res := range resPods {
|
|
|
uid := res.UID
|
|
uid := res.UID
|
|
|
if uid != "" {
|
|
if uid != "" {
|
|
|
resPodsUID = append(resPodsUID, res)
|
|
resPodsUID = append(resPodsUID, res)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ droppedNoUID = append(droppedNoUID, fmt.Sprintf("%s/%s", res.Namespace, res.Pod))
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if len(droppedNoUID) > 0 {
|
|
|
|
|
+ log.Debugf("CostModel.ComputeAllocation: dropped %d pod results lacking UID during UID-ingestion filter: %v", len(droppedNoUID), droppedNoUID)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if len(resPodsUID) > 0 {
|
|
if len(resPodsUID) > 0 {
|
|
|
resPods = resPodsUID
|
|
resPods = resPodsUID
|
|
|
} else {
|
|
} else {
|
|
@@ -94,7 +102,10 @@ func (cm *CostModel) buildPodMap(window opencost.Window, podMap map[podKey]*pod,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ preApplyMapSize := len(podMap)
|
|
|
applyPodResults(window, resolution, podMap, resPods, ingestPodUID, podUIDKeyMap)
|
|
applyPodResults(window, resolution, podMap, resPods, ingestPodUID, podUIDKeyMap)
|
|
|
|
|
+ log.Debugf("CostModel.ComputeAllocation: buildPodMap window=%s: prom returned %d pod results, %d post-UID-filter, podMap grew by %d (now %d)",
|
|
|
|
|
+ window, preFilterCount, len(resPods), len(podMap)-preApplyMapSize, len(podMap))
|
|
|
|
|
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
@@ -143,6 +154,8 @@ func applyPodResults(window opencost.Window, resolution time.Duration, podMap ma
|
|
|
|
|
|
|
|
allocStart, allocEnd := calculateStartAndEnd(res.Data, resolution, window)
|
|
allocStart, allocEnd := calculateStartAndEnd(res.Data, resolution, window)
|
|
|
if allocStart.IsZero() || allocEnd.IsZero() {
|
|
if allocStart.IsZero() || allocEnd.IsZero() {
|
|
|
|
|
+ log.Debugf("CostModel.ComputeAllocation: dropping pod %s/%s (cluster=%s, uid=%q): zero allocStart/allocEnd from %d data points, window=%s",
|
|
|
|
|
+ namespace, podName, cluster, res.UID, len(res.Data), window)
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
|
|
|