Move MemoryLimit to Execution Environment
This commit is contained in:
@ -8,6 +8,8 @@ class ExecutionEnvironment < ApplicationRecord
|
||||
|
||||
VALIDATION_COMMAND = 'whoami'
|
||||
DEFAULT_CPU_LIMIT = 20
|
||||
DEFAULT_MEMORY_LIMIT = 256
|
||||
MINIMUM_MEMORY_LIMIT = 4
|
||||
|
||||
after_initialize :set_default_values
|
||||
|
||||
@ -21,7 +23,7 @@ class ExecutionEnvironment < ApplicationRecord
|
||||
validate :working_docker_image?, if: :validate_docker_image?
|
||||
validates :docker_image, presence: true
|
||||
validates :memory_limit,
|
||||
numericality: {greater_than_or_equal_to: DockerClient::MINIMUM_MEMORY_LIMIT, only_integer: true}, presence: true
|
||||
numericality: {greater_than_or_equal_to: MINIMUM_MEMORY_LIMIT, only_integer: true}, presence: true
|
||||
validates :network_enabled, boolean_presence: true
|
||||
validates :name, presence: true
|
||||
validates :permitted_execution_time, numericality: {only_integer: true}, presence: true
|
||||
|
@ -19,7 +19,7 @@
|
||||
.help-block.form-text = t('.hints.exposed_ports_list')
|
||||
.form-group
|
||||
= f.label(:memory_limit)
|
||||
= f.number_field(:memory_limit, class: 'form-control', min: DockerClient::MINIMUM_MEMORY_LIMIT, value: f.object.memory_limit || DockerClient::DEFAULT_MEMORY_LIMIT)
|
||||
= f.number_field(:memory_limit, class: 'form-control', min: ExecutionEnvironment::MINIMUM_MEMORY_LIMIT, value: f.object.memory_limit || ExecutionEnvironment::DEFAULT_MEMORY_LIMIT)
|
||||
.form-group
|
||||
= f.label(:cpu_limit)
|
||||
= f.number_field(:cpu_limit, class: 'form-control', min: 1, step: 1, value: f.object.cpu_limit || ExecutionEnvironment::DEFAULT_CPU_LIMIT)
|
||||
|
@ -6,7 +6,7 @@ class AddMemoryLimitToExecutionEnvironments < ActiveRecord::Migration[4.2]
|
||||
|
||||
reversible do |direction|
|
||||
direction.up do
|
||||
ExecutionEnvironment.update(memory_limit: DockerClient::DEFAULT_MEMORY_LIMIT)
|
||||
ExecutionEnvironment.update(memory_limit: ExecutionEnvironment::DEFAULT_MEMORY_LIMIT)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -8,10 +8,8 @@ class DockerClient
|
||||
end
|
||||
|
||||
CONTAINER_WORKSPACE_PATH = '/workspace' # '/home/python/workspace' #'/tmp/workspace'
|
||||
DEFAULT_MEMORY_LIMIT = 256
|
||||
# Ralf: I suggest to replace this with the environment variable. Ask Hauke why this is not the case!
|
||||
LOCAL_WORKSPACE_ROOT = File.expand_path(config[:workspace_root])
|
||||
MINIMUM_MEMORY_LIMIT = 4
|
||||
RECYCLE_CONTAINERS = false
|
||||
RETRY_COUNT = 2
|
||||
MINIMUM_CONTAINER_LIFETIME = 10.minutes
|
||||
|
@ -152,7 +152,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
trait :default_memory_limit do
|
||||
memory_limit { DockerClient::DEFAULT_MEMORY_LIMIT }
|
||||
memory_limit { ExecutionEnvironment::DEFAULT_MEMORY_LIMIT }
|
||||
end
|
||||
|
||||
trait :default_cpu_limit do
|
||||
|
@ -16,7 +16,7 @@ describe ExecutionEnvironment do
|
||||
end
|
||||
|
||||
it 'validates the minimum value of the memory limit' do
|
||||
execution_environment.update(memory_limit: DockerClient::MINIMUM_MEMORY_LIMIT / 2)
|
||||
execution_environment.update(memory_limit: ExecutionEnvironment::MINIMUM_MEMORY_LIMIT / 2)
|
||||
expect(execution_environment.errors[:memory_limit]).to be_present
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user