Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/oom/recorder.go cleanOOMRecord函数保留的record问题 #844

Closed
Zz-zheng-Zz opened this issue Aug 7, 2023 · 3 comments · Fixed by #883
Closed

pkg/oom/recorder.go cleanOOMRecord函数保留的record问题 #844

Zz-zheng-Zz opened this issue Aug 7, 2023 · 3 comments · Fixed by #883
Labels
kind/bug Something isn't working

Comments

@Zz-zheng-Zz
Copy link

Zz-zheng-Zz commented Aug 7, 2023

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]
@Zz-zheng-Zz Zz-zheng-Zz added the kind/bug Something isn't working label Aug 7, 2023
@qmhu
Copy link
Member

qmhu commented Aug 11, 2023

I think this is a bug, would you like to fix it ?

@Zz-zheng-Zz
Copy link
Author

Sure, but I’m not sure how to request permission to submit code and initiate a PR. emmmm0.0

@qmhu
Copy link
Member

qmhu commented Aug 21, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants