Merge "limit rabbitmq CPU usage"

This commit is contained in:
Zuul 2019-08-02 18:35:21 +00:00 committed by Gerrit Code Review
commit 9acc76ed22
2 changed files with 42 additions and 0 deletions

View File

@ -200,6 +200,31 @@ class BaseHelm(object):
cpus.append(c)
return cpus
def _get_platform_res_limit(self):
"""
On All-In-One, not all CPUs and Mem are used for platform services.
It needs to limit the CPU and Mem usage of some services which use too
many resources.
"""
limit_enabled = False
limit_cpus = 0
limit_mem_mib = 0
system = self._get_system()
if system.system_type == constants.TIS_AIO_BUILD:
limit_enabled = True
controller_0 = self.dbapi.ihost_get_by_hostname(
constants.CONTROLLER_0_HOSTNAME)
platform_cpus = self._get_host_cpu_list(
controller_0, function=constants.PLATFORM_FUNCTION, threads=True)
limit_cpus = max(len(platform_cpus), 1)
host_memory = self.dbapi.imemory_get_by_ihost(controller_0.id)
for mem in host_memory:
limit_mem_mib += mem.platform_reserved_mib
return limit_enabled, limit_cpus, limit_mem_mib
def get_namespaces(self):
"""
Return list of namespaces supported by this chart

View File

@ -18,11 +18,28 @@ class RabbitmqHelm(openstack.OpenstackBaseHelm):
CHART = common.HELM_CHART_RABBITMQ
def get_overrides(self, namespace=None):
limit_enabled, limit_cpus, limit_mem_mib = self._get_platform_res_limit()
overrides = {
common.HELM_NS_OPENSTACK: {
'pod': {
'replicas': {
'server': self._num_controllers()
},
'resources': {
'enabled': limit_enabled,
'prometheus_rabbitmq_exporter': {
'limits': {
'cpu': "%d000m" % (limit_cpus),
'memory': "%dMi" % (limit_mem_mib)
}
},
'server': {
'limits': {
'cpu': "%d000m" % (limit_cpus),
'memory': "%dMi" % (limit_mem_mib)
}
}
}
},
'endpoints': self._get_endpoints_overrides(),