Move the error handler to the api querier
to catch the ws normal close error for all Execute requests
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/gorilla/websocket"
|
||||
nomadApi "github.com/hashicorp/nomad/api"
|
||||
"github.com/openHPI/poseidon/internal/config"
|
||||
"io"
|
||||
@@ -99,7 +100,10 @@ func (nc *nomadAPIClient) Execute(runnerID string,
|
||||
return 1, fmt.Errorf("error retrieving allocation info: %w", err)
|
||||
}
|
||||
exitCode, err := nc.client.Allocations().Exec(ctx, allocation, TaskName, tty, command, stdin, stdout, stderr, nil, nil)
|
||||
if err != nil {
|
||||
if err != nil && websocket.IsCloseError(err, websocket.CloseNormalClosure) {
|
||||
log.WithError(err).Info("The exit code could not be received.")
|
||||
return 0, nil
|
||||
} else if err != nil {
|
||||
return 1, fmt.Errorf("error executing command in allocation: %w", err)
|
||||
}
|
||||
return exitCode, nil
|
||||
|
Reference in New Issue
Block a user