Skip to content

Commit

Permalink
Add a memory limit constraint on deployments
Browse files Browse the repository at this point in the history
This is based on the worker's memory_threshold setting

Fixes ManageIQ#20163
  • Loading branch information
carbonin committed May 20, 2020
1 parent 786b234 commit f6f5d60
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/models/miq_worker/container_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def configure_worker_deployment(definition, replicas = 0)
container[:image] = "#{container_image_namespace}/#{container_image_name}:#{container_image_tag}"
container[:env] << {:name => "WORKER_CLASS_NAME", :value => self.class.name}
container[:env] << {:name => "BUNDLER_GROUPS", :value => self.class.bundler_groups.join(",")}
container[:resources] = resource_constraints
end

def scale_deployment
Expand All @@ -25,6 +26,15 @@ def zone_selector
{"#{Vmdb::Appliance.PRODUCT_NAME.downcase}/zone-#{MiqServer.my_zone}" => "true"}
end

def resource_constraints
mem_threshold = worker_settings[:memory_threshold]
{
:limits => {
:memory => "#{mem_threshold / 1.megabyte}Mi",
}
}
end

def container_image_namespace
ENV["CONTAINER_IMAGE_NAMESPACE"]
end
Expand Down

0 comments on commit f6f5d60

Please sign in to comment.