-
Notifications
You must be signed in to change notification settings - Fork 39.3k
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
CRI: Symlink docker logs to CRI defined log path. #34858
CRI: Symlink docker logs to CRI defined log path. #34858
Conversation
443e931
to
98f4d07
Compare
@k8s-bot cri test this. |
node e2e test is #34877 |
@resouer Thanks! |
98f4d07
to
d125b3b
Compare
Add one more commit to add the legacy container log location support. |
if err != nil { | ||
return fmt.Errorf("failed to start container %q: %v", containerID, err) | ||
} | ||
// TODO: Should we stop the container if an error occurs during start. |
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.
I think so. If not, dockershim/kubelet doesn't know there is an error happened.
@@ -269,7 +277,8 @@ func makeMounts(opts *kubecontainer.RunContainerOptions, container *api.Containe | |||
// here we just add a random id to make the path unique for different instances | |||
// of the same container. | |||
cid := makeUID() | |||
containerLogPath := path.Join(opts.PodContainerDir, cid) | |||
containerLogPath := filepath.Join(opts.PodContainerDir, cid) | |||
// TODO: We should try to use os interface here. | |||
fs, err := os.Create(containerLogPath) |
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.
Replace this with m.osInterface.Create
?
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.
A small problem is that makeMounts
is not a member function of m
. We can easily change that, just don't know whether we should make this change just for the unit test.
Reviewed 8 of 14 files at r1. pkg/kubelet/dockershim/docker_container.go, line 240 at r1 (raw file):
If there is no label, maybe we can just return an empty path and don't error out? Comments from Reviewable |
pkg/kubelet/dockershim/docker_container.go, line 194 at r2 (raw file):
|
pkg/kubelet/dockershim/docker_container.go, line 240 at r1 (raw file):
|
pkg/kubelet/dockershim/docker_container.go, line 194 at r2 (raw file):
|
pkg/kubelet/dockershim/docker_container.go, line 194 at r2 (raw file):
|
2501f1c
to
5a4ab5b
Compare
5a4ab5b
to
007dfb7
Compare
@k8s-bot cri test this. |
LGTM |
} | ||
// Create container log symlink. | ||
if err := ds.createContainerLogSymlink(containerID); err != nil { | ||
// Stop the container if the symlink creation fails. |
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.
Discussed with @Random-Liu offline. We'll not stop the container here as the shim has no context of how to stop a user container properly. Since not being able to create a symlink should be rare, the function will just return an error to let kubelet report an event.
@Random-Liu let's prioritize this one to unblock the unit test PR :-) |
@yujuhong ACK. Will address this soon. |
007dfb7
to
4de3d4f
Compare
@yujuhong Addressed comments. The change I made:
|
@k8s-bot cri test this. |
/lgtm |
Jenkins verification failed for commit 4de3d4f2d7a83ca9369ec34754385816a1b6bf53. Full PR test history. The magic incantation to run this job again is |
4de3d4f
to
fad4672
Compare
Rebase and sent again, apply LGTM based on #34858 (comment) |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Jenkins GCE etcd3 e2e failed for commit fad4672. Full PR test history. The magic incantation to run this job again is |
Automatic merge from submit-queue |
Automatic merge from submit-queue CRI: Refactor kuberuntime unit test Based on #34858 This PR: 1) Refactor the fake runtime service and some kuberuntime unit test. 2) Add better garbage collection unit test. 3) Fix init container unit test which isn't testing correctly. Some other unit tests may also need to be fixed. 4) Add pod log directory garbage collection unit test. @feiskyer @yujuhong /cc @kubernetes/sig-node
Automatic merge from submit-queue CRI: Add kuberuntime container logs Based on #34858. The first 2 commits are from #34858. And the last 2 commits are new. This PR added kuberuntime container logs support and add unit test for it. I've tested all the functions manually, and I'll send another PR to write a node e2e test for container log. **_Notice: current implementation doesn't support log rotation**_, which means that: - It will not retrieve logs in rotated log file. - If log rotation happens when following the log: - If the rotation is using create mode, we'll still follow the old file. - If the rotation is using copytruncate, we'll be reading at the original position and get nothing. To solve these issues, kubelet needs to rotate the log itself, or at least kubelet should be able to control the the behavior of log rotator. These are doable but out of the scope of 1.5 and will be addressed in future release. @yujuhong @feiskyer @yifan-gu /cc @kubernetes/sig-node
This is causing us issues with cri-o/cri-o#162. Has this problem been resolved, and if not where does the issue lie (the Docker or k8s side)? |
This PR symlink docker logs to the CRI defined log path.
I manually test myself, and it works. We still need some more unit test and a node e2e test.
@resouer is working on a node e2e test #34661.
For the unit test, the current
MakeFakePodSandbox
andMakeFakeContainer
is not enough for unit test, because I need to create multiple instances for one container and sandbox to test garbage collection.I'll send a separate PR to refactor the unit test framework in kuberuntime and finish the unit test.
@yujuhong @feiskyer
/cc @kubernetes/sig-node
This change is