Merge pull request #4863 from crosbymichael/log-dir

[cri] ensure log dir is created
This commit is contained in:
Phil Estes 2020-12-18 07:06:38 -05:00 committed by GitHub
commit ce7024558f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -156,6 +156,9 @@ func (c *criService) seccompEnabled() bool {
// openLogFile opens/creates a container log file. // openLogFile opens/creates a container log file.
func openLogFile(path string) (*os.File, error) { 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) return os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0640)
} }