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:
Konrad Hanff
2021-06-07 16:31:15 +02:00
committed by Sebastian Serth
parent 0978a3be83
commit 598de3bcff
6 changed files with 33 additions and 1 deletions

View File

@ -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')