mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Merge pull request #106441 from yjjy0921/master
create resultsDir if the folder not exists
This commit is contained in:
commit
b4fbd12c3a
@ -58,6 +58,13 @@ func configureAndRunWithEnv(env Getenver) error {
|
|||||||
// Print the output to stdout and a logfile which will be returned
|
// Print the output to stdout and a logfile which will be returned
|
||||||
// as part of the results tarball.
|
// as part of the results tarball.
|
||||||
logFilePath := filepath.Join(resultsDir, logFileName)
|
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)
|
logFile, err := os.Create(logFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create log file %v: %w", logFilePath, err)
|
return fmt.Errorf("failed to create log file %v: %w", logFilePath, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user