Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
1197: crictl rm to also remove container log files #1367
1197: crictl rm to also remove container log files #1367
Changes from 2 commits
67679ee
64e373b
09b9303
5afb4c7
949545e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this save for the log rotation? We would also possible remove files which are not rotated logs but other files, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible, although the rotations attach to the file name so it's unlikely, e.g. this was from my test with cri-o:
Another container would be e.g. 1.log, but a user could have backed up a 0.log.bak, and this code would delete that too. I wasn't sure if the log rotation always follows this format though.
Reading https://kubernetes.io/docs/concepts/cluster-administration/logging/ the rotation in /var/log should only be performed by kubelet, so I could use that as a guide, removing files in this format in that directory and ignoring rotations outside it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like kubelet uses a very similar pattern: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/logs/container_log_manager.go#L312
For the time being I'll do the same and just add the missing dot; I'm averse to adding hardcoded references to the dir, especially because it seems a bit more variable under Windows (the doc mentions C:\var\logs and C:\var\log\pods).