资源限制没值,就传默认值

dev_forum
daiao 5 years ago
parent 0af2270f20
commit 1dfa7a3bf9

@ -442,12 +442,18 @@ class ApplicationController < ActionController::Base
shixun.shixun_service_configs.each do |config| shixun.shixun_service_configs.each do |config|
mirror = config.mirror_repository mirror = config.mirror_repository
if mirror.name.present? if mirror.name.present?
# 资源限制没有就传默认值。
cpu_limit = config.cpu_limit.presence || 1
cpu_request = config.lower_cpu_limit.presence || 0.1
memory_limit = config.memory_limit.presence || 1024
request_limit = config.resource_limit.presence || 10
resource_limit = config.resource_limit.presence || 10000
container << {:image => mirror.name, container << {:image => mirror.name,
:cpuLimit => config.cpu_limit, :cpuLimit => cpu_limit,
:cpuRequest => config.lower_cpu_limit, :cpuRequest => cpu_request,
:memoryLimit => "#{config.memory_limit}M", :memoryLimit => "#{memory_limit}M",
:memoryRequest => "#{config.request_limit}M", :memoryRequest => "#{request_limit}M",
:resourceLimit => "#{config.resource_limit}K", :resourceLimit => "#{resource_limit}K",
:type => mirror.try(:main_type) == "1" ? "main" : "sub"} :type => mirror.try(:main_type) == "1" ? "main" : "sub"}
end end
end end

Loading…
Cancel
Save