limit rabbitmq CPU usage
On AIO, the rabbitmq CPU usage should be based on the platform cores. Change-Id: Ic73a5c82cd37cc0c8e3119577842a10fb1167a69 Closes-Bug: 1834796 Signed-off-by: Bin Yang <bin.yang@intel.com>
This commit is contained in:
parent
22a60625f1
commit
4c5ff8f627
|
@ -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
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in New Issue