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

audit log: set default max size #16543

Merged
merged 1 commit into from
May 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/minikube/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ func LogCommandEnd(id string) error {
}

func getStartIndex(entryCount int) int {
maxEntries := viper.GetInt(config.MaxAuditEntries)
// default to 1000 entries
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm... I wonder what is the best thing to do to if the audilog was already more than that in the files...should delete it ?

Copy link
Member Author

@spowelljr spowelljr May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will truncate the existing file, so if it's currently 2000 lines, it will truncate it to the last 1000

maxEntries := 1000
if viper.IsSet(config.MaxAuditEntries) {
maxEntries = viper.GetInt(config.MaxAuditEntries)
}
startIndex := entryCount - maxEntries
if maxEntries <= 0 || startIndex <= 0 {
return 0
Expand Down