Merge pull request #106441 from yjjy0921/master

create resultsDir if the folder not exists
This commit is contained in:
Kubernetes Prow Robot 2022-06-01 13:39:46 -07:00 committed by GitHub
commit b4fbd12c3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,6 +58,13 @@ func configureAndRunWithEnv(env Getenver) error {
// Print the output to stdout and a logfile which will be returned
// as part of the results tarball.
logFilePath := filepath.Join(resultsDir, logFileName)
// ensure the resultsDir actually exists
if _, err := os.Stat(resultsDir); os.IsNotExist(err) {
log.Printf("The resultsDir %v does not exist, will create it", resultsDir)
if mkdirErr := os.Mkdir(resultsDir, 0755); mkdirErr != nil {
return fmt.Errorf("failed to create log directory %v: %w", resultsDir, mkdirErr)
}
}
logFile, err := os.Create(logFilePath)
if err != nil {
return fmt.Errorf("failed to create log file %v: %w", logFilePath, err)