Catch the "Close normal" error
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
nomadApi "github.com/hashicorp/nomad/api"
|
nomadApi "github.com/hashicorp/nomad/api"
|
||||||
"github.com/hashicorp/nomad/nomad/structs"
|
"github.com/hashicorp/nomad/nomad/structs"
|
||||||
"github.com/openHPI/poseidon/internal/config"
|
"github.com/openHPI/poseidon/internal/config"
|
||||||
@ -352,7 +353,10 @@ func (a *APIClient) ExecuteCommand(allocationID string,
|
|||||||
return a.executeCommandInteractivelyWithStderr(allocationID, ctx, command, stdin, stdout, stderr)
|
return a.executeCommandInteractivelyWithStderr(allocationID, ctx, command, stdin, stdout, stderr)
|
||||||
}
|
}
|
||||||
exitCode, err := a.apiQuerier.Execute(allocationID, ctx, command, tty, stdin, stdout, stderr)
|
exitCode, err := a.apiQuerier.Execute(allocationID, ctx, command, tty, stdin, stdout, stderr)
|
||||||
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 API: %w", err)
|
return 1, fmt.Errorf("error executing command in API: %w", err)
|
||||||
}
|
}
|
||||||
return exitCode, nil
|
return exitCode, nil
|
||||||
|
Reference in New Issue
Block a user