mirror of https://github.com/k3s-io/k3s
Merge pull request #50509 from feiskyer/link-logs
Automatic merge from submit-queue (batch tested with PRs 50988, 50509, 52660, 52663, 52250). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Create container log symlink for all containers **What this PR does / why we need it**: dockershim only makes log symlink for running containers now, we should also create the log symlink for failed containers. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #50499 **Special notes for your reviewer**: **Release note**: ```release-note NONE ```pull/6/head
commit
0ea979a2f2
|
@ -232,18 +232,21 @@ func (ds *dockerService) removeContainerLogSymlink(containerID string) error {
|
||||||
// StartContainer starts the container.
|
// StartContainer starts the container.
|
||||||
func (ds *dockerService) StartContainer(containerID string) error {
|
func (ds *dockerService) StartContainer(containerID string) error {
|
||||||
err := ds.client.StartContainer(containerID)
|
err := ds.client.StartContainer(containerID)
|
||||||
if err != nil {
|
|
||||||
err = transformStartContainerError(err)
|
// Create container log symlink for all containers (including failed ones).
|
||||||
return fmt.Errorf("failed to start container %q: %v", containerID, err)
|
if linkError := ds.createContainerLogSymlink(containerID); linkError != nil {
|
||||||
}
|
|
||||||
// Create container log symlink.
|
|
||||||
if err := ds.createContainerLogSymlink(containerID); err != nil {
|
|
||||||
// Do not stop the container if we failed to create symlink because:
|
// Do not stop the container if we failed to create symlink because:
|
||||||
// 1. This is not a critical failure.
|
// 1. This is not a critical failure.
|
||||||
// 2. We don't have enough information to properly stop container here.
|
// 2. We don't have enough information to properly stop container here.
|
||||||
// Kubelet will surface this error to user via an event.
|
// Kubelet will surface this error to user via an event.
|
||||||
return err
|
return linkError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
err = transformStartContainerError(err)
|
||||||
|
return fmt.Errorf("failed to start container %q: %v", containerID, err)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue