@@ -196,7 +196,7 @@ func (ex *RunExecutor) Run(ctx context.Context) (err error) {
196196
197197 ex .setJobCredentials (ctx )
198198
199- if err := ex .prepareJobWorkingDir (ctx ); err != nil {
199+ if err := ex .setJobWorkingDir (ctx ); err != nil {
200200 ex .SetJobStateWithTerminationReason (
201201 ctx ,
202202 types .JobStateFailed ,
@@ -352,7 +352,7 @@ func (ex *RunExecutor) setJobCredentials(ctx context.Context) {
352352 log .Trace (ctx , "Job credentials" , "uid" , ex .jobUid , "gid" , ex .jobGid , "home" , ex .jobHomeDir )
353353}
354354
355- func (ex * RunExecutor ) prepareJobWorkingDir (ctx context.Context ) error {
355+ func (ex * RunExecutor ) setJobWorkingDir (ctx context.Context ) error {
356356 var err error
357357 if ex .jobSpec .WorkingDir == nil {
358358 ex .jobWorkingDir , err = os .Getwd ()
@@ -372,9 +372,6 @@ func (ex *RunExecutor) prepareJobWorkingDir(ctx context.Context) error {
372372 }
373373 }
374374 log .Trace (ctx , "Job working dir" , "path" , ex .jobWorkingDir )
375- if err := common .MkdirAll (ctx , ex .jobWorkingDir , ex .jobUid , ex .jobGid ); err != nil {
376- return fmt .Errorf ("create working directory: %w" , err )
377- }
378375 return nil
379376}
380377
@@ -429,6 +426,9 @@ func (ex *RunExecutor) execJob(ctx context.Context, jobLogFile io.Writer) error
429426 }
430427 cmd .WaitDelay = ex .killDelay // kills the process if it doesn't exit in time
431428
429+ if err := common .MkdirAll (ctx , ex .jobWorkingDir , ex .jobUid , ex .jobGid ); err != nil {
430+ return fmt .Errorf ("create working directory: %w" , err )
431+ }
432432 cmd .Dir = ex .jobWorkingDir
433433
434434 // User must be already set
0 commit comments