pkg/oom/recorder.go cleanOOMRecord函数保留的record问题
func (r *PodOOMRecorder) cleanOOMRecords(oomRecords []OOMRecord) []OOMRecord {
r.mu.Lock()
defer r.mu.Unlock()
if len(oomRecords) > r.OOMRecordMaxNumber {
records := oomRecords
sort.Slice(records, func(i, j int) bool {
return records[i].OOMAt.Before(records[j].OOMAt)
})
records = records[0:r.OOMRecordMaxNumber]
oomRecords = records
}
return oomRecords
}
Describe the bug
您好,想请教一下,这段代码用于清理超过默认保留数量的OOM历史数据,但是看起来排序后,将时间久远的数据排列在数组前面,然后保留了数组前默认条数的数据,也就是说保留了旧数据,而删除了新数据,这样做的考量是什么呢 Reproduce steps
Expected behavior
Screenshots
Environment (please complete the following information):
- K8S Version: [e.g. 1.19]
- Crane Version: [e.g. 0.1.0]
- Browser [e.g. chrome, safari]
I think this is a bug, would you like to fix it ?
Sure, but I’m not sure how to request permission to submit code and initiate a PR. emmmm0.0
Sure, but I’m not sure how to request permission to submit code and initiate a PR. emmmm0.0
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork