Skip to content

Commit c8c14cd

Browse files
authored
Fix Go err race (#3243)
1 parent 1e44d83 commit c8c14cd

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

runner/cmd/runner/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ func start(tempDir string, homeDir string, httpPort int, sshPort int, logLevel i
2828
return fmt.Errorf("create default log file: %w", err)
2929
}
3030
defer func() {
31-
err = defaultLogFile.Close()
32-
if err != nil {
33-
log.Error(context.TODO(), "Failed to close default log file", "err", err)
31+
closeErr := defaultLogFile.Close()
32+
if closeErr != nil {
33+
log.Error(context.TODO(), "Failed to close default log file", "err", closeErr)
3434
}
3535
}()
3636

runner/internal/executor/executor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,8 @@ func (ex *RunExecutor) execJob(ctx context.Context, jobLogFile io.Writer) error
422422
cmd := exec.CommandContext(ctx, ex.jobSpec.Commands[0], ex.jobSpec.Commands[1:]...)
423423
cmd.Cancel = func() error {
424424
// returns error on Windows
425-
if err = cmd.Process.Signal(os.Interrupt); err != nil {
426-
return fmt.Errorf("send interrupt signal: %w", err)
425+
if signalErr := cmd.Process.Signal(os.Interrupt); signalErr != nil {
426+
return fmt.Errorf("send interrupt signal: %w", signalErr)
427427
}
428428
return nil
429429
}

runner/internal/shim/host_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type hostInfo struct {
2424
func WriteHostInfo(dir string, resources Resources) error {
2525
path := filepath.Join(dir, "host_info.json")
2626
// if host_info.json already exists, do nothing and return os.ErrExist
27-
if _, err := os.Stat(path); errors.Is(err, os.ErrExist) {
27+
if _, err := os.Stat(path); !errors.Is(err, os.ErrNotExist) {
2828
return err
2929
}
3030

0 commit comments

Comments
 (0)