Skip to content

Commit 8021292

Browse files
authored
Merge pull request kubernetes#124025 from saschagrunert/log-container-status
Continue streaming kubelet logs when runtime is unavailable
2 parents 535e833 + ff95ae0 commit 8021292

File tree

1 file changed

+9
-0
lines changed
  • staging/src/k8s.io/cri-client/pkg/logs

1 file changed

+9
-0
lines changed

staging/src/k8s.io/cri-client/pkg/logs/logs.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import (
3030
"time"
3131

3232
"github.com/fsnotify/fsnotify"
33+
"google.golang.org/grpc/codes"
34+
"google.golang.org/grpc/status"
3335

3436
v1 "k8s.io/api/core/v1"
3537
internalapi "k8s.io/cri-api/pkg/apis"
@@ -422,6 +424,13 @@ func ReadLogs(ctx context.Context, logger *klog.Logger, path, containerID string
422424
func isContainerRunning(ctx context.Context, logger *klog.Logger, id string, r internalapi.RuntimeService) (bool, error) {
423425
resp, err := r.ContainerStatus(ctx, id, false)
424426
if err != nil {
427+
// Assume that the container is still running when the runtime is
428+
// unavailable. Most runtimes support that containers can be in running
429+
// state even if their CRI server is not available right now.
430+
if status.Code(err) == codes.Unavailable {
431+
return true, nil
432+
}
433+
425434
return false, err
426435
}
427436
status := resp.GetStatus()

0 commit comments

Comments
 (0)