Use Nomad jobs as runners instead of allocations
As we can't control which allocations are destroyed when downscaling a job, we decided to use Nomad jobs as our runners. Thus for each runner we prewarm for an environment, a corresponding job is created in Nomad. We create a default job that serves as a template for the runners. Using this, already existing execution environments can easily be restored, once Poseidon is restarted.
This commit is contained in:

committed by
Maximilian Paß

parent
8de489929e
commit
c7d59810e5
@ -29,7 +29,7 @@ type MiddlewareTestSuite struct {
|
||||
|
||||
func (s *MiddlewareTestSuite) SetupTest() {
|
||||
s.manager = &runner.ManagerMock{}
|
||||
s.runner = runner.NewNomadAllocation("runner", nil)
|
||||
s.runner = runner.NewNomadJob("runner", nil)
|
||||
s.capturedRunner = nil
|
||||
s.runnerRequest = func(runnerId string) *http.Request {
|
||||
path, err := s.router.Get("test-runner-id").URL(RunnerIdKey, runnerId)
|
||||
@ -92,7 +92,7 @@ type RunnerRouteTestSuite struct {
|
||||
func (s *RunnerRouteTestSuite) SetupTest() {
|
||||
s.runnerManager = &runner.ManagerMock{}
|
||||
s.router = NewRouter(s.runnerManager, nil)
|
||||
s.runner = runner.NewNomadAllocation("some-id", nil)
|
||||
s.runner = runner.NewNomadJob("some-id", nil)
|
||||
s.executionId = "execution-id"
|
||||
s.runner.Add(s.executionId, &dto.ExecutionRequest{})
|
||||
s.runnerManager.On("Get", s.runner.Id()).Return(s.runner, nil)
|
||||
|
@ -128,7 +128,9 @@ type webSocketProxy struct {
|
||||
|
||||
// upgradeConnection upgrades a connection to a websocket and returns a webSocketProxy for this connection.
|
||||
func upgradeConnection(writer http.ResponseWriter, request *http.Request) (webSocketConnection, error) {
|
||||
connUpgrader := websocket.Upgrader{}
|
||||
connUpgrader := websocket.Upgrader{CheckOrigin: func(r *http.Request) bool {
|
||||
return true
|
||||
}}
|
||||
connection, err := connUpgrader.Upgrade(writer, request, nil)
|
||||
if err != nil {
|
||||
log.WithError(err).Warn("Connection upgrade failed")
|
||||
|
@ -309,7 +309,7 @@ func TestRawToCodeOceanWriter(t *testing.T) {
|
||||
|
||||
func newNomadAllocationWithMockedApiClient(runnerId string) (r runner.Runner, mock *nomad.ExecutorAPIMock) {
|
||||
mock = &nomad.ExecutorAPIMock{}
|
||||
r = runner.NewNomadAllocation(runnerId, mock)
|
||||
r = runner.NewNomadJob(runnerId, mock)
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user