Add button to synchronize all execution environments
This adds a button to the execution environment index page that, when clicked, causes all execution environments to be synchronized to the runner management (Poseidon) by creating or replacing them. CodeOcean does not synchronize it's execution environments on startup or when a new runner management configuration is used for the first time. The administrator has to manually start this process by pressing this button. The equivalent for syncing just one execution environment is updating it.
This commit is contained in:

committed by
Sebastian Serth

parent
0978a3be83
commit
598de3bcff
@ -164,6 +164,19 @@ class ExecutionEnvironmentsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def synchronize_all_to_poseidon
|
||||
authorize ExecutionEnvironment
|
||||
|
||||
return unless RUNNER_MANAGEMENT_PRESENT
|
||||
|
||||
success = ExecutionEnvironment.all.map(&:copy_to_poseidon).all?
|
||||
if success
|
||||
redirect_to ExecutionEnvironment, notice: t('execution_environments.index.synchronize_all.success')
|
||||
else
|
||||
redirect_to ExecutionEnvironment, alert: t('execution_environments.index.synchronize_all.failure')
|
||||
end
|
||||
end
|
||||
|
||||
def copy_execution_environment_to_poseidon
|
||||
unless RUNNER_MANAGEMENT_PRESENT && @execution_environment.copy_to_poseidon
|
||||
t('execution_environments.form.errors.not_synced_to_poseidon')
|
||||
|
@ -8,4 +8,8 @@ class ExecutionEnvironmentPolicy < AdminOnlyPolicy
|
||||
[:index?].each do |action|
|
||||
define_method(action) { admin? || teacher? }
|
||||
end
|
||||
|
||||
def synchronize_all_to_poseidon?
|
||||
admin?
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,9 @@
|
||||
h1 = ExecutionEnvironment.model_name.human(count: 2)
|
||||
h1.d-inline-block = ExecutionEnvironment.model_name.human(count: 2)
|
||||
|
||||
- if ExecutionEnvironment::RUNNER_MANAGEMENT_PRESENT
|
||||
= button_to( { action: :synchronize_all_to_poseidon, method: :post }, { form_class: 'float-right mb-2', class: 'btn btn-success' })
|
||||
i.fa.fa-upload
|
||||
= t('execution_environments.index.synchronize_all.button')
|
||||
|
||||
.table-responsive
|
||||
table.table
|
||||
|
@ -287,6 +287,10 @@ de:
|
||||
not_synced_to_poseidon: Die Ausführungsumgebung wurde erstellt, aber aufgrund eines Fehlers nicht zu Poseidon synchronisiert.
|
||||
index:
|
||||
shell: Shell
|
||||
synchronize_all:
|
||||
button: Alle synchronisieren
|
||||
success: Alle Ausführungsumgebungen wurden erfolgreich synchronisiert.
|
||||
failure: Beim Synchronisieren mindestens einer Ausführungsumgebung ist ein Fehler aufgetreten.
|
||||
shell:
|
||||
command: Befehl
|
||||
headline: Shell
|
||||
|
@ -287,6 +287,10 @@ en:
|
||||
not_synced_to_poseidon: The ExecutionEnvironment was created but not synced to Poseidon due to an error.
|
||||
index:
|
||||
shell: Shell
|
||||
synchronize_all:
|
||||
button: Synchronize all
|
||||
success: All execution environemnts were synchronized successfully.
|
||||
failure: At least one execution environment could not be synchronised due to an error.
|
||||
shell:
|
||||
command: Command
|
||||
headline: Shell
|
||||
|
@ -66,6 +66,8 @@ Rails.application.routes.draw do
|
||||
post 'shell', as: :execute_command, action: :execute_command
|
||||
get :statistics
|
||||
end
|
||||
|
||||
post :synchronize_all_to_poseidon, on: :collection
|
||||
end
|
||||
|
||||
post '/import_exercise' => 'exercises#import_exercise'
|
||||
|
Reference in New Issue
Block a user