From 2e442ea4852d3a4a4bb01438032da3e1896fe3f0 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 17 Dec 2020 15:04:39 -0500 Subject: [PATCH] [cri] ensure log dir is created containerd is responsible for creating the log but there is no code to ensure that the log dir exists. While kubelet should have created this there can be times where this is not the case and this can cause stuck tasks. Signed-off-by: Michael Crosby --- pkg/cri/server/helpers_linux.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/cri/server/helpers_linux.go b/pkg/cri/server/helpers_linux.go index f367865c2..1e207d38a 100644 --- a/pkg/cri/server/helpers_linux.go +++ b/pkg/cri/server/helpers_linux.go @@ -156,6 +156,9 @@ func (c *criService) seccompEnabled() bool { // openLogFile opens/creates a container log file. func openLogFile(path string) (*os.File, error) { + if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { + return nil, err + } return os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0640) }