Merge pull request #1103 from openHPI/fix/execution_environment_update_without_runner_management

Check Runner management status in execution environment updates
This commit is contained in:
Sebastian Serth
2021-12-08 00:33:41 +01:00
committed by GitHub

View File

@ -80,7 +80,7 @@ class ExecutionEnvironment < ApplicationRecord
def validate_docker_image?
# We only validate the code execution with the provided image if there is at least one container to test with.
pool_size.positive? && docker_image.present? && !Rails.env.test?
pool_size.positive? && docker_image.present? && !Rails.env.test? && Runner.management_active?
end
def working_docker_image?
@ -105,7 +105,7 @@ class ExecutionEnvironment < ApplicationRecord
end
def delete_runner_environment
Runner.strategy_class.remove_environment(self)
Runner.strategy_class.remove_environment(self) if Runner.management_active?
rescue Runner::Error => e
unless errors.include?(:docker_image)
errors.add(:docker_image, "error: #{e}")
@ -115,7 +115,7 @@ class ExecutionEnvironment < ApplicationRecord
def sync_runner_environment
previous_saved_environment = self.class.find(id)
Runner.strategy_class.sync_environment(previous_saved_environment)
Runner.strategy_class.sync_environment(previous_saved_environment) if Runner.management_active?
rescue Runner::Error => e
unless errors.include?(:docker_image)
errors.add(:docker_image, "error: #{e}")