Skip to content

Commit f47d061

Browse files
committed
fix some error handling
1 parent fa7042f commit f47d061

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

pkg/blockcontroller/shellcontroller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,14 @@ func (sc *ShellController) resetTerminalState(logCtx context.Context) {
197197
ctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)
198198
defer cancelFn()
199199
wfile, statErr := filestore.WFS.Stat(ctx, sc.BlockId, wavebase.BlockFile_Term)
200-
if statErr == fs.ErrNotExist || wfile.Size == 0 {
200+
if statErr == fs.ErrNotExist {
201+
return
202+
}
203+
if statErr != nil {
204+
log.Printf("error statting term file: %v\n", statErr)
205+
return
206+
}
207+
if wfile.Size == 0 {
201208
return
202209
}
203210
blocklogger.Debugf(logCtx, "[conndebug] resetTerminalState: resetting terminal state\n")

pkg/blockcontroller/shelljobcontroller.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,11 @@ func (sjc *ShellJobController) Stop(graceful bool, newStatus string, destroy boo
199199
}
200200
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
201201
defer cancel()
202-
jobcontroller.DetachJobFromBlock(ctx, jobId, false)
203-
err := jobcontroller.TerminateJobManager(ctx, jobId)
202+
err := jobcontroller.DetachJobFromBlock(ctx, jobId, false)
203+
if err != nil {
204+
log.Printf("error detaching job from block: %v\n", err)
205+
}
206+
err = jobcontroller.TerminateJobManager(ctx, jobId)
204207
if err != nil {
205208
log.Printf("error terminating job manager: %v\n", err)
206209
}
@@ -290,7 +293,14 @@ func (sjc *ShellJobController) resetTerminalState(logCtx context.Context) {
290293
}
291294

292295
wfile, statErr := filestore.WFS.Stat(ctx, jobId, jobcontroller.JobOutputFileName)
293-
if statErr == fs.ErrNotExist || wfile.Size == 0 {
296+
if statErr == fs.ErrNotExist {
297+
return
298+
}
299+
if statErr != nil {
300+
log.Printf("error statting job output file: %v\n", statErr)
301+
return
302+
}
303+
if wfile.Size == 0 {
294304
return
295305
}
296306

0 commit comments

Comments
 (0)