Merge "Support ram limit per pool" into feature/zuulv3
This commit is contained in:
commit
046eea4df8
@ -432,6 +432,11 @@ Example::
|
||||
limit the number of servers. If not defined nodepool can create as many
|
||||
servers the tenant allows.
|
||||
|
||||
``max-ram``
|
||||
Maximum ram usable from this pool. This can be used to limit the amount of
|
||||
ram allocated by nodepool. If not defined nodepool can use as much ram as
|
||||
the tenant allows.
|
||||
|
||||
``availability-zones`` (list)
|
||||
A list of availability zones to use.
|
||||
|
||||
|
@ -63,6 +63,7 @@ class ProviderPool(ConfigValue):
|
||||
if (other.labels != self.labels or
|
||||
other.max_cores != self.max_cores or
|
||||
other.max_servers != self.max_servers or
|
||||
other.max_ram != self.max_ram or
|
||||
other.azs != self.azs or
|
||||
other.networks != self.networks):
|
||||
return False
|
||||
@ -162,6 +163,7 @@ class OpenStackProviderConfig(ProviderConfig):
|
||||
self.pools[pp.name] = pp
|
||||
pp.max_cores = pool.get('max-cores', None)
|
||||
pp.max_servers = pool.get('max-servers', None)
|
||||
pp.max_ram = pool.get('max-ram', None)
|
||||
pp.azs = pool.get('availability-zones')
|
||||
pp.networks = pool.get('networks', [])
|
||||
pp.auto_floating_ip = bool(pool.get('auto-floating-ip', True))
|
||||
@ -248,6 +250,7 @@ class OpenStackProviderConfig(ProviderConfig):
|
||||
'auto-floating-ip': bool,
|
||||
'max-cores': int,
|
||||
'max-servers': int,
|
||||
'max-ram': int,
|
||||
'labels': [pool_label],
|
||||
'availability-zones': [str],
|
||||
}
|
||||
|
@ -357,6 +357,7 @@ class OpenStackNodeRequestHandler(NodeRequestHandler):
|
||||
# to math.inf representing infinity that can be calculated with.
|
||||
pool_quota = QuotaInformation(cores=self.pool.max_cores,
|
||||
instances=self.pool.max_servers,
|
||||
ram=self.pool.max_ram,
|
||||
default=math.inf)
|
||||
pool_quota.subtract(
|
||||
self.manager.estimatedNodepoolQuotaUsed(self.zk, self.pool))
|
||||
@ -389,6 +390,7 @@ class OpenStackNodeRequestHandler(NodeRequestHandler):
|
||||
# to math.inf representing infinity that can be calculated with.
|
||||
pool_quota = QuotaInformation(cores=self.pool.max_cores,
|
||||
instances=self.pool.max_servers,
|
||||
ram=self.pool.max_ram,
|
||||
default=math.inf)
|
||||
pool_quota.subtract(needed_quota)
|
||||
return pool_quota.non_negative()
|
||||
|
39
nodepool/tests/fixtures/node_quota_pool_ram.yaml
vendored
Normal file
39
nodepool/tests/fixtures/node_quota_pool_ram.yaml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
elements-dir: .
|
||||
images-dir: '{images_dir}'
|
||||
|
||||
zookeeper-servers:
|
||||
- host: {zookeeper_host}
|
||||
port: {zookeeper_port}
|
||||
chroot: {zookeeper_chroot}
|
||||
|
||||
labels:
|
||||
- name: fake-label
|
||||
min-ready: 0
|
||||
|
||||
providers:
|
||||
- name: fake-provider
|
||||
cloud: fake
|
||||
driver: fake
|
||||
region-name: fake-region
|
||||
rate: 0.0001
|
||||
diskimages:
|
||||
- name: fake-image
|
||||
pools:
|
||||
- name: main
|
||||
max-ram: 16384
|
||||
labels:
|
||||
- name: fake-label
|
||||
diskimage: fake-image
|
||||
min-ram: 8192
|
||||
|
||||
diskimages:
|
||||
- name: fake-image
|
||||
elements:
|
||||
- fedora
|
||||
- vm
|
||||
release: 21
|
||||
env-vars:
|
||||
TMPDIR: /opt/dib_tmp
|
||||
DIB_IMAGE_CACHE: /opt/dib_cache
|
||||
DIB_CLOUD_IMAGES: http://download.fedoraproject.org/pub/fedora/linux/releases/test/21-Beta/Cloud/Images/x86_64/
|
||||
BASE_IMAGE_FILE: Fedora-Cloud-Base-20141029-21_Beta.x86_64.qcow2
|
@ -234,6 +234,9 @@ class TestLauncher(tests.DBTestCase):
|
||||
self._test_node_assignment_at_quota(
|
||||
config='node_quota_pool_instances.yaml')
|
||||
|
||||
def test_node_assignment_at_pool_quota_ram(self):
|
||||
self._test_node_assignment_at_quota(
|
||||
config='node_quota_pool_ram.yaml')
|
||||
|
||||
def test_node_assignment_at_cloud_cores_quota(self):
|
||||
self._test_node_assignment_at_quota(config='node_quota_cloud.yaml',
|
||||
|
Loading…
x
Reference in New Issue
Block a user