diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index af0158cfd..f01ad4b6b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -442,12 +442,18 @@ class ApplicationController < ActionController::Base shixun.shixun_service_configs.each do |config| mirror = config.mirror_repository 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, - :cpuLimit => config.cpu_limit, - :cpuRequest => config.lower_cpu_limit, - :memoryLimit => "#{config.memory_limit}M", - :memoryRequest => "#{config.request_limit}M", - :resourceLimit => "#{config.resource_limit}K", + :cpuLimit => cpu_limit, + :cpuRequest => cpu_request, + :memoryLimit => "#{memory_limit}M", + :memoryRequest => "#{request_limit}M", + :resourceLimit => "#{resource_limit}K", :type => mirror.try(:main_type) == "1" ? "main" : "sub"} end end