From 76210a2d85cfb8f8aab2f252e0cb06a9e2930ba3 Mon Sep 17 00:00:00 2001 From: Lakshmi Prasanna Goutham Pratapa Date: Fri, 13 Jul 2018 19:17:53 +0530 Subject: [PATCH] Apply Resource Constraints to Openstack Services This commit is to apply resource-constraints only to few OpenStack services. Commit to apply constraints to other services will be made in coming commits. Partially-Implements: blueprint resource-constraints Change-Id: Icafa54baca24d2de64238222a5677b9d8b90e2aa --- ansible/library/kolla_docker.py | 33 +++++++- ansible/roles/aodh/defaults/main.yml | 8 ++ ansible/roles/aodh/handlers/main.yml | 4 + ansible/roles/aodh/tasks/config.yml | 1 + ansible/roles/barbican/defaults/main.yml | 6 ++ ansible/roles/barbican/handlers/main.yml | 3 + ansible/roles/barbican/tasks/config.yml | 1 + ansible/roles/blazar/defaults/main.yml | 4 + ansible/roles/blazar/handlers/main.yml | 2 + ansible/roles/blazar/tasks/config.yml | 1 + ansible/roles/ceilometer/defaults/main.yml | 6 ++ ansible/roles/ceilometer/handlers/main.yml | 3 + ansible/roles/ceilometer/tasks/config.yml | 1 + ansible/roles/chrony/defaults/main.yml | 3 + ansible/roles/chrony/handlers/main.yml | 1 + ansible/roles/chrony/tasks/config.yml | 1 + ansible/roles/cinder/defaults/main.yml | 8 ++ ansible/roles/cinder/handlers/main.yml | 4 + ansible/roles/cinder/tasks/config.yml | 1 + ansible/roles/cloudkitty/defaults/main.yml | 6 ++ ansible/roles/cloudkitty/handlers/main.yml | 2 + ansible/roles/cloudkitty/tasks/config.yml | 1 + ansible/roles/collectd/defaults/main.yml | 3 + ansible/roles/collectd/handlers/main.yml | 1 + ansible/roles/collectd/tasks/config.yml | 1 + ansible/roles/common/defaults/main.yml | 7 ++ ansible/roles/common/handlers/main.yml | 3 + ansible/roles/common/tasks/config.yml | 1 + ansible/roles/congress/defaults/main.yml | 6 ++ ansible/roles/congress/handlers/main.yml | 3 + ansible/roles/congress/tasks/config.yml | 1 + ansible/roles/designate/defaults/main.yml | 15 ++++ ansible/roles/designate/handlers/main.yml | 7 ++ ansible/roles/designate/tasks/config.yml | 1 + ansible/roles/elasticsearch/defaults/main.yml | 3 + ansible/roles/elasticsearch/handlers/main.yml | 1 + ansible/roles/elasticsearch/tasks/config.yml | 1 + ansible/roles/etcd/defaults/main.yml | 2 + ansible/roles/etcd/handlers/main.yml | 1 + ansible/roles/etcd/tasks/config.yml | 1 + ansible/roles/freezer/defaults/main.yml | 5 ++ ansible/roles/freezer/handlers/main.yml | 2 + ansible/roles/freezer/tasks/config.yml | 1 + ansible/roles/glance/defaults/main.yml | 6 ++ ansible/roles/glance/handlers/main.yml | 2 + ansible/roles/glance/tasks/config.yml | 1 + ansible/roles/gnocchi/defaults/main.yml | 7 ++ ansible/roles/gnocchi/handlers/main.yml | 3 + ansible/roles/gnocchi/tasks/config.yml | 1 + ansible/roles/grafana/defaults/main.yml | 3 + ansible/roles/grafana/handlers/main.yml | 1 + ansible/roles/grafana/tasks/config.yml | 1 + ansible/roles/haproxy/defaults/main.yml | 5 ++ ansible/roles/haproxy/handlers/main.yml | 2 + ansible/roles/haproxy/tasks/config.yml | 1 + ansible/roles/heat/defaults/main.yml | 7 ++ ansible/roles/heat/handlers/main.yml | 3 + ansible/roles/heat/tasks/config.yml | 1 + ansible/roles/nova/tasks/config.yml | 1 + doc/source/reference/resource-constraints.rst | 44 +++++++++-- tests/test_kolla_docker.py | 76 +++++++++++++++++++ 61 files changed, 323 insertions(+), 8 deletions(-) diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py index 4d4fe73145..e0fe632868 100644 --- a/ansible/library/kolla_docker.py +++ b/ansible/library/kolla_docker.py @@ -301,7 +301,8 @@ class DockerWorker(object): self.compare_volumes(container_info) or self.compare_volumes_from(container_info) or self.compare_environment(container_info) or - self.compare_container_state(container_info) + self.compare_container_state(container_info) or + self.compare_dimensions(container_info) ) def compare_ipc_mode(self, container_info): @@ -438,6 +439,36 @@ class DockerWorker(object): if new_state != current_state: return True + def compare_dimensions(self, container_info): + new_dimensions = self.params.get('dimensions') + # NOTE(mgoddard): The names used by Docker are inconsisent between + # configuration of a container's resources and the resources in + # container_info['HostConfig']. This provides a mapping between the + # two. + dimension_map = { + 'mem_limit': 'Memory', 'mem_reservation': 'MemoryReservation', + 'memswap_limit': 'MemorySwap', 'cpu_period': 'CpuPeriod', + 'cpu_quota': 'CpuQuota', 'cpu_shares': 'CpuShares', + 'cpuset_cpus': 'CpusetCpus', 'cpuset_mems': 'CpusetMems', + 'kernel_memory': 'KernelMemory', 'blkio_weight': 'BlkioWeight'} + unsupported = set(new_dimensions.keys()) - \ + set(dimension_map.keys()) + if unsupported: + self.module.exit_json( + failed=True, msg=repr("Unsupported dimensions"), + unsupported_dimensions=unsupported) + current_dimensions = container_info['HostConfig'] + for key1, key2 in dimension_map.items(): + # NOTE(mgoddard): If a resource has been explicitly requested, + # check for a match. Otherwise, ensure is is set to the default. + if key1 in new_dimensions: + if new_dimensions[key1] != current_dimensions[key2]: + return True + elif current_dimensions[key2]: + # The default values of all currently supported resources are + # '' or 0 - both falsey. + return True + def parse_image(self): full_image = self.params.get('image') diff --git a/ansible/roles/aodh/defaults/main.yml b/ansible/roles/aodh/defaults/main.yml index 9ecc4cb3f0..ac3eadf423 100644 --- a/ansible/roles/aodh/defaults/main.yml +++ b/ansible/roles/aodh/defaults/main.yml @@ -13,6 +13,7 @@ aodh_services: - "aodh:/var/lib/aodh/" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/aodh/aodh:/var/lib/kolla/venv/lib/python2.7/site-packages/aodh' if aodh_dev_mode | bool else '' }}" + dimensions: "{{ aodh_api_dimensions }}" aodh-evaluator: container_name: aodh_evaluator group: aodh-evaluator @@ -23,6 +24,7 @@ aodh_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/aodh/aodh:/var/lib/kolla/venv/lib/python2.7/site-packages/aodh' if aodh_dev_mode | bool else '' }}" + dimensions: "{{ aodh_evaluator_dimensions }}" aodh-listener: container_name: aodh_listener group: aodh-listener @@ -33,6 +35,7 @@ aodh_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/aodh/aodh:/var/lib/kolla/venv/lib/python2.7/site-packages/aodh' if aodh_dev_mode | bool else '' }}" + dimensions: "{{ aodh_listener_dimensions }}" aodh-notifier: container_name: aodh_notifier group: aodh-notifier @@ -43,6 +46,7 @@ aodh_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/aodh/aodh:/var/lib/kolla/venv/lib/python2.7/site-packages/aodh' if aodh_dev_mode | bool else '' }}" + dimensions: "{{ aodh_notifier_dimensions }}" #################### @@ -74,6 +78,10 @@ aodh_notifier_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ d aodh_notifier_tag: "{{ aodh_tag }}" aodh_notifier_image_full: "{{ aodh_notifier_image }}:{{ aodh_notifier_tag }}" +aodh_api_dimensions: "{{ default_container_dimensions }}" +aodh_evaluator_dimensions: "{{ default_container_dimensions }}" +aodh_listener_dimensions: "{{ default_container_dimensions }}" +aodh_notifier_dimensions: "{{ default_container_dimensions }}" #################### # OpenStack diff --git a/ansible/roles/aodh/handlers/main.yml b/ansible/roles/aodh/handlers/main.yml index e79d4af839..ad1905119e 100644 --- a/ansible/roles/aodh/handlers/main.yml +++ b/ansible/roles/aodh/handlers/main.yml @@ -14,6 +14,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -39,6 +40,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -63,6 +65,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -87,6 +90,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/aodh/tasks/config.yml b/ansible/roles/aodh/tasks/config.yml index f99c68334c..6cfc07e7f2 100644 --- a/ansible/roles/aodh/tasks/config.yml +++ b/ansible/roles/aodh/tasks/config.yml @@ -111,6 +111,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" + dimensions: "{{ item.value.dimensions }}" register: check_aodh_containers when: - kolla_action != "config" diff --git a/ansible/roles/barbican/defaults/main.yml b/ansible/roles/barbican/defaults/main.yml index a1a06edf64..12e6bba073 100644 --- a/ansible/roles/barbican/defaults/main.yml +++ b/ansible/roles/barbican/defaults/main.yml @@ -13,6 +13,7 @@ barbican_services: - "barbican:/var/lib/barbican/" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/barbican/barbican:/var/lib/kolla/venv/lib/python2.7/site-packages/barbican' if barbican_dev_mode | bool else '' }}" + dimensions: "{{ barbican_api_dimensions }}" barbican-keystone-listener: container_name: barbican_keystone_listener group: barbican-keystone-listener @@ -23,6 +24,7 @@ barbican_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/barbican/barbican:/var/lib/kolla/venv/lib/python2.7/site-packages/barbican' if barbican_dev_mode | bool else '' }}" + dimensions: "{{ barbican_keystone_listener_dimensions }}" barbican-worker: container_name: barbican_worker group: barbican-worker @@ -33,6 +35,7 @@ barbican_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/barbican/barbican:/var/lib/kolla/venv/lib/python2.7/site-packages/barbican' if barbican_dev_mode | bool else '' }}" + dimensions: "{{ barbican_worker_dimensions }}" #################### @@ -61,6 +64,9 @@ barbican_worker_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ barbican_worker_tag: "{{ barbican_tag }}" barbican_worker_image_full: "{{ barbican_worker_image }}:{{ barbican_worker_tag }}" +barbican_api_dimensions: "{{ default_container_dimensions }}" +barbican_keystone_listener_dimensions: "{{ default_container_dimensions }}" +barbican_worker_dimensions: "{{ default_container_dimensions }}" #################### # OpenStack diff --git a/ansible/roles/barbican/handlers/main.yml b/ansible/roles/barbican/handlers/main.yml index e451d07d17..ea164f9a9e 100644 --- a/ansible/roles/barbican/handlers/main.yml +++ b/ansible/roles/barbican/handlers/main.yml @@ -14,6 +14,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -40,6 +41,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -64,6 +66,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/barbican/tasks/config.yml b/ansible/roles/barbican/tasks/config.yml index f0318d2aa4..5c6b554705 100644 --- a/ansible/roles/barbican/tasks/config.yml +++ b/ansible/roles/barbican/tasks/config.yml @@ -130,6 +130,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" + dimensions: "{{ item.value.dimensions }}" register: check_barbican_containers when: - kolla_action != "config" diff --git a/ansible/roles/blazar/defaults/main.yml b/ansible/roles/blazar/defaults/main.yml index 6cd6a69030..6a1ddcd3ab 100644 --- a/ansible/roles/blazar/defaults/main.yml +++ b/ansible/roles/blazar/defaults/main.yml @@ -12,6 +12,7 @@ blazar_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/blazar/blazar:/var/lib/kolla/venv/lib/python2.7/site-packages/blazar' if blazar_dev_mode | bool else '' }}" + dimensions: "{{ blazar_api_dimensions }}" blazar-manager: container_name: blazar_manager group: blazar-manager @@ -22,6 +23,7 @@ blazar_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/blazar/blazar:/var/lib/kolla/venv/lib/python2.7/site-packages/blazar' if blazar_dev_mode | bool else '' }}" + dimensions: "{{ blazar_manager_dimensions }}" #################### @@ -51,6 +53,8 @@ blazar_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ dock blazar_api_tag: "{{ blazar_tag }}" blazar_api_image_full: "{{ blazar_api_image }}:{{ blazar_api_tag }}" +blazar_api_dimensions: "{{ default_container_dimensions }}" +blazar_manager_dimensions: "{{ default_container_dimensions }}" #################### # OpenStack diff --git a/ansible/roles/blazar/handlers/main.yml b/ansible/roles/blazar/handlers/main.yml index 64626bae09..f410f249c3 100644 --- a/ansible/roles/blazar/handlers/main.yml +++ b/ansible/roles/blazar/handlers/main.yml @@ -14,6 +14,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -38,6 +39,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/blazar/tasks/config.yml b/ansible/roles/blazar/tasks/config.yml index b12809959f..f86c815dc1 100644 --- a/ansible/roles/blazar/tasks/config.yml +++ b/ansible/roles/blazar/tasks/config.yml @@ -89,6 +89,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" + dimensions: "{{ item.value.dimensions }}" register: check_blazar_containers when: - kolla_action != "config" diff --git a/ansible/roles/ceilometer/defaults/main.yml b/ansible/roles/ceilometer/defaults/main.yml index 4af83c9cbd..654a24de22 100644 --- a/ansible/roles/ceilometer/defaults/main.yml +++ b/ansible/roles/ceilometer/defaults/main.yml @@ -12,6 +12,7 @@ ceilometer_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/ceilometer/ceilometer:/var/lib/kolla/venv/lib/python2.7/site-packages/ceilometer' if ceilometer_dev_mode | bool else '' }}" + dimensions: "{{ ceilometer_notification_dimensions }}" ceilometer-central: container_name: ceilometer_central group: ceilometer-central @@ -23,6 +24,7 @@ ceilometer_services: - "ceilometer:/var/lib/ceilometer/" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/ceilometer/ceilometer:/var/lib/kolla/venv/lib/python2.7/site-packages/ceilometer' if ceilometer_dev_mode | bool else '' }}" + dimensions: "{{ ceilometer_central_dimensions }}" ceilometer-compute: container_name: ceilometer_compute group: ceilometer-compute @@ -37,6 +39,7 @@ ceilometer_services: - "kolla_logs:/var/log/kolla/" - "nova_libvirt:/var/lib/libvirt" - "{{ kolla_dev_repos_directory ~ '/ceilometer/ceilometer:/var/lib/kolla/venv/lib/python2.7/site-packages/ceilometer' if ceilometer_dev_mode | bool else '' }}" + dimensions: "{{ ceilometer_compute_dimensions }}" #################### @@ -57,6 +60,9 @@ ceilometer_compute_image: "{{ docker_registry ~ '/' if docker_registry else '' } ceilometer_compute_tag: "{{ ceilometer_tag }}" ceilometer_compute_image_full: "{{ ceilometer_compute_image }}:{{ ceilometer_compute_tag }}" +ceilometer_notification_dimensions: "{{ default_container_dimensions }}" +ceilometer_central_dimensions: "{{ default_container_dimensions }}" +ceilometer_compute_dimensions: "{{ default_container_dimensions }}" #################### # OpenStack diff --git a/ansible/roles/ceilometer/handlers/main.yml b/ansible/roles/ceilometer/handlers/main.yml index 4a74a8205a..5348beab33 100644 --- a/ansible/roles/ceilometer/handlers/main.yml +++ b/ansible/roles/ceilometer/handlers/main.yml @@ -17,6 +17,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -46,6 +47,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -74,6 +76,7 @@ image: "{{ service.image }}" privileged: "{{ service.privileged | default(False) }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/ceilometer/tasks/config.yml b/ansible/roles/ceilometer/tasks/config.yml index 150e38666b..d54d7748a6 100644 --- a/ansible/roles/ceilometer/tasks/config.yml +++ b/ansible/roles/ceilometer/tasks/config.yml @@ -196,6 +196,7 @@ image: "{{ item.value.image }}" privileged: "{{ item.value.privileged | default(False) }}" volumes: "{{ item.value.volumes | reject('equalto', '')|list }}" + dimensions: "{{ item.value.dimensions }}" register: check_ceilometer_containers when: - kolla_action != "config" diff --git a/ansible/roles/chrony/defaults/main.yml b/ansible/roles/chrony/defaults/main.yml index 31ec936401..68e702b7c3 100644 --- a/ansible/roles/chrony/defaults/main.yml +++ b/ansible/roles/chrony/defaults/main.yml @@ -12,6 +12,7 @@ chrony_services: - "{{ node_config_directory }}/chrony/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla" + dimensions: "{{ chrony_dimensions }}" chrony_bindaddress: "{{ kolla_internal_vip_address }}" @@ -21,3 +22,5 @@ chrony_bindaddress: "{{ kolla_internal_vip_address }}" chrony_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-chrony" chrony_tag: "{{ openstack_release }}" chrony_image_full: "{{ chrony_image }}:{{ chrony_tag }}" + +chrony_dimensions: "{{ default_container_dimensions }}" diff --git a/ansible/roles/chrony/handlers/main.yml b/ansible/roles/chrony/handlers/main.yml index 7c23f92f2b..67b224cc36 100644 --- a/ansible/roles/chrony/handlers/main.yml +++ b/ansible/roles/chrony/handlers/main.yml @@ -11,6 +11,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/chrony/tasks/config.yml b/ansible/roles/chrony/tasks/config.yml index 40e88629e0..002de5bcb0 100644 --- a/ansible/roles/chrony/tasks/config.yml +++ b/ansible/roles/chrony/tasks/config.yml @@ -43,6 +43,7 @@ image: "{{ item.value.image }}" privileged: "{{ item.value.privileged }}" volumes: "{{ item.value.volumes }}" + dimensions: "{{ item.value.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[item.value.group] diff --git a/ansible/roles/cinder/defaults/main.yml b/ansible/roles/cinder/defaults/main.yml index 9725988db2..4905a66467 100644 --- a/ansible/roles/cinder/defaults/main.yml +++ b/ansible/roles/cinder/defaults/main.yml @@ -12,6 +12,7 @@ cinder_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/cinder/cinder:/var/lib/kolla/venv/lib/python2.7/site-packages/cinder' if cinder_dev_mode | bool else '' }}" + dimensions: "{{ cinder_api_dimensions }}" cinder-scheduler: container_name: cinder_scheduler group: cinder-scheduler @@ -22,6 +23,7 @@ cinder_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/cinder/cinder:/var/lib/kolla/venv/lib/python2.7/site-packages/cinder' if cinder_dev_mode | bool else '' }}" + dimensions: "{{ cinder_scheduler_dimensions }}" cinder-volume: container_name: cinder_volume group: cinder-volume @@ -39,6 +41,7 @@ cinder_services: - "{% if enable_iscsid | bool %}iscsi_info:/etc/iscsi{% endif %}" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/cinder/cinder:/var/lib/kolla/venv/lib/python2.7/site-packages/cinder' if cinder_dev_mode | bool else '' }}" + dimensions: "{{ cinder_volume_dimensions }}" cinder-backup: container_name: cinder_backup group: cinder-backup @@ -54,6 +57,7 @@ cinder_services: - "{% if enable_iscsid | bool %}iscsi_info:/etc/iscsi{% endif %}" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/cinder/cinder:/var/lib/kolla/venv/lib/python2.7/site-packages/cinder' if cinder_dev_mode | bool else '' }}" + dimensions: "{{ cinder_backup_dimensions }}" #################### # Ceph @@ -129,6 +133,10 @@ cinder_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ dock cinder_api_tag: "{{ cinder_tag }}" cinder_api_image_full: "{{ cinder_api_image }}:{{ cinder_api_tag }}" +cinder_api_dimensions: "{{ default_container_dimensions }}" +cinder_backup_dimensions: "{{ default_container_dimensions }}" +cinder_scheduler_dimensions: "{{ default_container_dimensions }}" +cinder_volume_dimensions: "{{ default_container_dimensions }}" #################### # OpenStack diff --git a/ansible/roles/cinder/handlers/main.yml b/ansible/roles/cinder/handlers/main.yml index 80abedf90a..063b5a45b9 100644 --- a/ansible/roles/cinder/handlers/main.yml +++ b/ansible/roles/cinder/handlers/main.yml @@ -14,6 +14,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes | reject('equalto', '') | list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -39,6 +40,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes | reject('equalto', '') | list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -65,6 +67,7 @@ privileged: "{{ service.privileged | default(False) }}" ipc_mode: "{{ service.ipc_mode | default('') }}" volumes: "{{ service.volumes | reject('equalto', '') | list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -90,6 +93,7 @@ image: "{{ service.image }}" privileged: "{{ service.privileged | default(False) }}" volumes: "{{ service.volumes | reject('equalto', '') | list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/cinder/tasks/config.yml b/ansible/roles/cinder/tasks/config.yml index 3ff603e835..20ed1ccc9a 100644 --- a/ansible/roles/cinder/tasks/config.yml +++ b/ansible/roles/cinder/tasks/config.yml @@ -127,6 +127,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" + dimensions: "{{ item.value.dimensions }}" privileged: "{{ item.value.privileged | default(False) }}" ipc_mode: "{{ item.value.ipc_mode | default('') }}" register: check_cinder_containers diff --git a/ansible/roles/cloudkitty/defaults/main.yml b/ansible/roles/cloudkitty/defaults/main.yml index 688da5a4da..aec99f9cd9 100644 --- a/ansible/roles/cloudkitty/defaults/main.yml +++ b/ansible/roles/cloudkitty/defaults/main.yml @@ -12,6 +12,7 @@ cloudkitty_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/cloudkitty/cloudkitty:/var/lib/kolla/venv/lib/python2.7/site-packages/cloudkitty' if cloudkitty_dev_mode | bool else '' }}" + dimensions: "{{ cloudkitty_api_dimensions }}" cloudkitty-processor: container_name: "cloudkitty_processor" group: "cloudkitty-processor" @@ -22,6 +23,7 @@ cloudkitty_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/cloudkitty/cloudkitty:/var/lib/kolla/venv/lib/python2.7/site-packages/cloudkitty' if cloudkitty_dev_mode | bool else '' }}" + dimensions: "{{ cloudkitty_processor_dimensions }}" #################### @@ -46,6 +48,10 @@ cloudkitty_processor_image: "{{ docker_registry ~ '/' if docker_registry else '' cloudkitty_processor_tag: "{{ cloudkitty_tag }}" cloudkitty_processor_image_full: "{{ cloudkitty_processor_image }}:{{ cloudkitty_processor_tag }}" +cloudkitty_processor_diensions: "{{ default_container_dimensions }}" +cloudkitty_api_dimensions: "{{ default_container_dimensions }}" + + #################### # OpenStack #################### diff --git a/ansible/roles/cloudkitty/handlers/main.yml b/ansible/roles/cloudkitty/handlers/main.yml index 419b8978ef..d8b76fe32e 100644 --- a/ansible/roles/cloudkitty/handlers/main.yml +++ b/ansible/roles/cloudkitty/handlers/main.yml @@ -14,6 +14,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -39,6 +40,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/cloudkitty/tasks/config.yml b/ansible/roles/cloudkitty/tasks/config.yml index 359cbadf7d..6a4200f901 100644 --- a/ansible/roles/cloudkitty/tasks/config.yml +++ b/ansible/roles/cloudkitty/tasks/config.yml @@ -105,6 +105,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" + dimensions: "{{ item.value.dimensions }}" register: check_cloudkitty_containers when: - kolla_action != "config" diff --git a/ansible/roles/collectd/defaults/main.yml b/ansible/roles/collectd/defaults/main.yml index c6b9047453..50ac15af78 100644 --- a/ansible/roles/collectd/defaults/main.yml +++ b/ansible/roles/collectd/defaults/main.yml @@ -13,6 +13,7 @@ collectd_services: - "kolla_logs:/var/log/kolla/" - "/sys/:/sys/:ro" - "/dev/:/dev/:ro" + dimensions: "{{ collectd_dimensions }}" #################### # Docker @@ -21,6 +22,8 @@ collectd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker collectd_tag: "{{ openstack_release }}" collectd_image_full: "{{ collectd_image }}:{{ collectd_tag }}" +collectd_dimensions: "{{ default_container_dimensions }}" + #################### # OpenStack #################### diff --git a/ansible/roles/collectd/handlers/main.yml b/ansible/roles/collectd/handlers/main.yml index 708d5200b5..806482e4b5 100644 --- a/ansible/roles/collectd/handlers/main.yml +++ b/ansible/roles/collectd/handlers/main.yml @@ -13,6 +13,7 @@ image: "{{ service.image }}" privileged: "{{ service.privileged | default(False) }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/collectd/tasks/config.yml b/ansible/roles/collectd/tasks/config.yml index 8213cf1a6f..3577d535f3 100644 --- a/ansible/roles/collectd/tasks/config.yml +++ b/ansible/roles/collectd/tasks/config.yml @@ -68,6 +68,7 @@ image: "{{ item.value.image }}" privileged: "{{ item.value.privileged | default(False) }}" volumes: "{{ item.value.volumes }}" + dimensions: "{{ item.value.dimensions }}" register: check_collectd_containers when: - kolla_action != "config" diff --git a/ansible/roles/common/defaults/main.yml b/ansible/roles/common/defaults/main.yml index 34d5ebb9fb..2b0590704a 100644 --- a/ansible/roles/common/defaults/main.yml +++ b/ansible/roles/common/defaults/main.yml @@ -14,6 +14,7 @@ common_services: - "{{ node_config_directory }}/fluentd/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ fluentd_dimensions }}" kolla-toolbox: container_name: kolla_toolbox enabled: True @@ -28,6 +29,7 @@ common_services: - "/dev/:/dev/" - "/run/:/run/:shared" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ kolla_toolbox_dimensions }}" # DUMMY_ENVIRONMENT is needed because empty environment is not supported cron: container_name: cron @@ -39,6 +41,7 @@ common_services: - "{{ node_config_directory }}/cron/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ cron_dimensions }}" #################### @@ -47,6 +50,10 @@ common_services: common_install_type: "{{ kolla_install_type }}" common_tag: "{{ openstack_release }}" +cron_dimensions: "{{ default_container_dimensions }}" +kolla_toolbox_dimensions: "{{ default_container_dimensions }}" +fluentd_dimensions: "{{ default_container_dimensions }}" + kolla_toolbox_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ common_install_type }}-kolla-toolbox" kolla_toolbox_tag: "{{ common_tag }}" kolla_toolbox_image_full: "{{ kolla_toolbox_image }}:{{ kolla_toolbox_tag }}" diff --git a/ansible/roles/common/handlers/main.yml b/ansible/roles/common/handlers/main.yml index 4b32ae6b8b..96a36d1926 100644 --- a/ansible/roles/common/handlers/main.yml +++ b/ansible/roles/common/handlers/main.yml @@ -13,6 +13,7 @@ image: "{{ service.image }}" volumes: "{{ service.volumes }}" environment: "{{ service.environment }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - service.enabled | bool @@ -41,6 +42,7 @@ privileged: "{{ service.privileged | default(False) }}" volumes: "{{ service.volumes }}" environment: "{{ service.environment }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - service.enabled | bool @@ -67,6 +69,7 @@ image: "{{ service.image }}" volumes: "{{ service.volumes }}" environment: "{{ service.environment }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - service.enabled | bool diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml index 7f4cd9c2ca..cc663e2755 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -255,6 +255,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes }}" + dimensions: "{{ item.value.dimensions }}" privileged: "{{ item.value.privileged | default(False) }}" environment: "{{ item.value.environment }}" register: check_common_containers diff --git a/ansible/roles/congress/defaults/main.yml b/ansible/roles/congress/defaults/main.yml index 63ba5e03ca..2193ba9c0d 100644 --- a/ansible/roles/congress/defaults/main.yml +++ b/ansible/roles/congress/defaults/main.yml @@ -12,6 +12,7 @@ congress_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/congress/congress:/var/lib/kolla/venv/lib/python2.7/site-packages/congress' if congress_dev_mode | bool else '' }}" + dimensions: "{{ congress_api_dimensions }}" congress-policy-engine: container_name: congress_policy_engine group: congress-policy-engine @@ -22,6 +23,7 @@ congress_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/congress/congress:/var/lib/kolla/venv/lib/python2.7/site-packages/congress' if congress_dev_mode | bool else '' }}" + dimensions: "{{ congress_policy_engine_dimensions }}" congress-datasource: container_name: congress_datasource group: congress-datasource @@ -32,6 +34,7 @@ congress_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/congress/congress:/var/lib/kolla/venv/lib/python2.7/site-packages/congress' if congress_dev_mode | bool else '' }}" + dimensions: "{{ congress_datasource_dimensions }}" #################### @@ -60,6 +63,9 @@ congress_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ do congress_api_tag: "{{ congress_tag }}" congress_api_image_full: "{{ congress_api_image }}:{{ congress_api_tag }}" +congress_api_dimensions: "{{ default_container_dimensions }}" +congress_policy_engine_dimensions: "{{ default_container_dimensions }}" +congress_datasource_dimensions: "{{ default_container_dimensions }}" #################### # OpenStack diff --git a/ansible/roles/congress/handlers/main.yml b/ansible/roles/congress/handlers/main.yml index d065d2521e..e71c2cc523 100644 --- a/ansible/roles/congress/handlers/main.yml +++ b/ansible/roles/congress/handlers/main.yml @@ -14,6 +14,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -38,6 +39,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -62,6 +64,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/congress/tasks/config.yml b/ansible/roles/congress/tasks/config.yml index 7d09577f79..120e15bb8f 100644 --- a/ansible/roles/congress/tasks/config.yml +++ b/ansible/roles/congress/tasks/config.yml @@ -87,6 +87,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" + dimensions: "{{ item.value.dimensions }}" register: check_congress_containers when: - kolla_action != "config" diff --git a/ansible/roles/designate/defaults/main.yml b/ansible/roles/designate/defaults/main.yml index 3af79afdff..7703a662a1 100644 --- a/ansible/roles/designate/defaults/main.yml +++ b/ansible/roles/designate/defaults/main.yml @@ -12,6 +12,7 @@ designate_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/designate/designate:/var/lib/kolla/venv/lib/python2.7/site-packages/designate' if designate_dev_mode | bool else '' }}" + dimensions: "{{ designate_api_dimensions }}" designate-backend-bind9: container_name: designate_backend_bind9 group: designate-backend-bind9 @@ -22,6 +23,7 @@ designate_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "designate_backend_bind9:/var/lib/named/" + dimensions: "{{ designate_backend_bind9_dimensions }}" designate-central: container_name: designate_central group: designate-central @@ -32,6 +34,7 @@ designate_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/designate/designate:/var/lib/kolla/venv/lib/python2.7/site-packages/designate' if designate_dev_mode | bool else '' }}" + dimensions: "{{ designate_central_dimensions }}" designate-mdns: container_name: designate_mdns group: designate-mdns @@ -42,6 +45,7 @@ designate_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/designate/designate:/var/lib/kolla/venv/lib/python2.7/site-packages/designate' if designate_dev_mode | bool else '' }}" + dimensions: "{{ designate_mdns_dimensions }}" designate-producer: container_name: designate_producer group: designate-producer @@ -52,6 +56,7 @@ designate_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/designate/designate:/var/lib/kolla/venv/lib/python2.7/site-packages/designate' if designate_dev_mode | bool else '' }}" + dimensions: "{{ designate_producer_dimensions }}" designate-worker: container_name: designate_worker group: designate-worker @@ -62,6 +67,7 @@ designate_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/designate/designate:/var/lib/kolla/venv/lib/python2.7/site-packages/designate' if designate_dev_mode | bool else '' }}" + dimensions: "{{ designate_worker_dimensions }}" designate-sink: container_name: designate_sink group: designate-sink @@ -72,6 +78,7 @@ designate_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/designate/designate:/var/lib/kolla/venv/lib/python2.7/site-packages/designate' if designate_dev_mode | bool else '' }}" + dimensions: "{{ designate_sink_dimensions }}" #################### @@ -120,6 +127,14 @@ designate_worker_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{ designate_worker_tag: "{{ designate_tag }}" designate_worker_image_full: "{{ designate_worker_image }}:{{ designate_worker_tag }}" +designate_api_dimensions: "{{ default_container_dimensions }}" +designate_backend_bind9_dimensions: "{{ default_container_dimensions }}" +designate_central_dimensions: "{{ default_container_dimensions }}" +designate_mdns_dimensions: "{{ default_container_dimensions }}" +designate_producer_dimensions: "{{ default_container_dimensions }}" +designate_worker_dimensions: "{{ default_container_dimensions }}" +designate_sink_dimensions: "{{ default_container_dimensions }}" + #################### # OpenStack #################### diff --git a/ansible/roles/designate/handlers/main.yml b/ansible/roles/designate/handlers/main.yml index 39d514ec93..eb9064fa09 100644 --- a/ansible/roles/designate/handlers/main.yml +++ b/ansible/roles/designate/handlers/main.yml @@ -12,6 +12,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -37,6 +38,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -61,6 +63,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -85,6 +88,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -109,6 +113,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -133,6 +138,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -159,6 +165,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/designate/tasks/config.yml b/ansible/roles/designate/tasks/config.yml index 3f4be6b6f9..7b57984c42 100644 --- a/ansible/roles/designate/tasks/config.yml +++ b/ansible/roles/designate/tasks/config.yml @@ -184,6 +184,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" + dimensions: "{{ item.value.dimensions }}" register: check_designate_containers when: - kolla_action != "config" diff --git a/ansible/roles/elasticsearch/defaults/main.yml b/ansible/roles/elasticsearch/defaults/main.yml index 9f6c4787bf..8be79d7cf8 100644 --- a/ansible/roles/elasticsearch/defaults/main.yml +++ b/ansible/roles/elasticsearch/defaults/main.yml @@ -11,6 +11,7 @@ elasticsearch_services: - "{{ node_config_directory }}/elasticsearch/:{{ container_config_directory }}/" - "/etc/localtime:/etc/localtime:ro" - "elasticsearch:/var/lib/elasticsearch/data" + dimensions: "{{ elasticsearch_dimensions }}" #################### @@ -26,3 +27,5 @@ es_java_opts: "{% if es_heap_size %}-Xms{{ es_heap_size }} -Xmx{{ es_heap_size } elasticsearch_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-elasticsearch" elasticsearch_tag: "{{ openstack_release }}" elasticsearch_image_full: "{{ elasticsearch_image }}:{{ elasticsearch_tag }}" + +elasticsearch_dimensions: "{{ default_container_dimensions }}" diff --git a/ansible/roles/elasticsearch/handlers/main.yml b/ansible/roles/elasticsearch/handlers/main.yml index df200bd0bb..31b82c9087 100644 --- a/ansible/roles/elasticsearch/handlers/main.yml +++ b/ansible/roles/elasticsearch/handlers/main.yml @@ -14,6 +14,7 @@ image: "{{ service.image }}" environment: "{{ service.environment }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/elasticsearch/tasks/config.yml b/ansible/roles/elasticsearch/tasks/config.yml index dca9f342f8..1b450b0f59 100644 --- a/ansible/roles/elasticsearch/tasks/config.yml +++ b/ansible/roles/elasticsearch/tasks/config.yml @@ -57,6 +57,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes }}" + dimensions: "{{ item.value.dimensions }}" environment: "{{ item.value.environment }}" register: check_elasticsearch_containers when: diff --git a/ansible/roles/etcd/defaults/main.yml b/ansible/roles/etcd/defaults/main.yml index b1ebfaf089..914a96deb0 100644 --- a/ansible/roles/etcd/defaults/main.yml +++ b/ansible/roles/etcd/defaults/main.yml @@ -29,6 +29,7 @@ etcd_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_etcd:/var/lib/etcd/" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ etcd_dimensions }}" #################### @@ -37,3 +38,4 @@ etcd_services: etcd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-etcd" etcd_tag: "{{ openstack_release }}" etcd_image_full: "{{ etcd_image }}:{{ etcd_tag }}" +etcd_dimensions: "{{ default_container_dimensions }}" diff --git a/ansible/roles/etcd/handlers/main.yml b/ansible/roles/etcd/handlers/main.yml index b3f40f094e..e5e83c02f3 100644 --- a/ansible/roles/etcd/handlers/main.yml +++ b/ansible/roles/etcd/handlers/main.yml @@ -13,6 +13,7 @@ image: "{{ service.image }}" environment: "{{ service.environment }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - service.enabled | bool diff --git a/ansible/roles/etcd/tasks/config.yml b/ansible/roles/etcd/tasks/config.yml index 4e5b2aa425..340d91ea10 100644 --- a/ansible/roles/etcd/tasks/config.yml +++ b/ansible/roles/etcd/tasks/config.yml @@ -34,6 +34,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes }}" + dimensions: "{{ item.value.dimensions }}" environment: "{{ item.value.environment }}" register: check_etcd_containers when: diff --git a/ansible/roles/freezer/defaults/main.yml b/ansible/roles/freezer/defaults/main.yml index 5112e76df9..f5eacf6f29 100644 --- a/ansible/roles/freezer/defaults/main.yml +++ b/ansible/roles/freezer/defaults/main.yml @@ -12,6 +12,7 @@ freezer_services: - "/etc/localtime:/etc/localtime:ro" - "freezer:/var/lib/freezer/" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ freezer_api_dimensions }}" freezer-scheduler: container_name: freezer_scheduler group: freezer-scheduler @@ -22,6 +23,7 @@ freezer_services: - "/etc/localtime:/etc/localtime:ro" - "freezer:/var/lib/freezer/" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ freezer_scheduler_dimensions }}" #################### @@ -38,6 +40,9 @@ freezer_scheduler_image: "{{ docker_registry ~ '/' if docker_registry else '' }} freezer_scheduler_tag: "{{ freezer_tag }}" freezer_scheduler_image_full: "{{ freezer_scheduler_image }}:{{ freezer_scheduler_tag }}" +freezer_api_dimensions: "{{ default_container_dimensions }}" +freezer_scheduler_dimensions: "{{ default_container_dimensions }}" + #################### # OpenStack #################### diff --git a/ansible/roles/freezer/handlers/main.yml b/ansible/roles/freezer/handlers/main.yml index 9318b2978a..91c9acdf8e 100644 --- a/ansible/roles/freezer/handlers/main.yml +++ b/ansible/roles/freezer/handlers/main.yml @@ -14,6 +14,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -39,6 +40,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/freezer/tasks/config.yml b/ansible/roles/freezer/tasks/config.yml index 8430046cd4..1edbd7b21c 100644 --- a/ansible/roles/freezer/tasks/config.yml +++ b/ansible/roles/freezer/tasks/config.yml @@ -102,6 +102,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes }}" + dimensions: "{{ item.value.dimensions }}" register: check_freezer_containers when: - kolla_action != "config" diff --git a/ansible/roles/glance/defaults/main.yml b/ansible/roles/glance/defaults/main.yml index a23d9c65a9..80e11f0f51 100644 --- a/ansible/roles/glance/defaults/main.yml +++ b/ansible/roles/glance/defaults/main.yml @@ -14,6 +14,7 @@ glance_services: - "{{ glance_file_datadir_volume }}:/var/lib/glance/" - "{{ kolla_dev_repos_directory ~ '/glance/glance:/var/lib/kolla/venv/lib/python2.7/site-packages/glance' if glance_dev_mode | bool else '' }}" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ glance_api_dimensions }}" glance-registry: container_name: glance_registry group: glance-registry @@ -24,6 +25,7 @@ glance_services: - "/etc/localtime:/etc/localtime:ro" - "{{ kolla_dev_repos_directory ~ '/glance/glance:/var/lib/kolla/venv/lib/python2.7/site-packages/glance' if glance_dev_mode | bool else '' }}" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ glance_registry_dimensions }}" #################### # Notification @@ -78,6 +80,10 @@ glance_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ dock glance_api_tag: "{{ glance_tag }}" glance_api_image_full: "{{ glance_api_image }}:{{ glance_api_tag }}" +glance_api_dimensions: "{{ default_container_dimensions }}" +glance_registry_dimensions: "{{ default_container_dimensions }}" + + #################### # Glance #################### diff --git a/ansible/roles/glance/handlers/main.yml b/ansible/roles/glance/handlers/main.yml index 3fdedb0b88..ff367fe997 100644 --- a/ansible/roles/glance/handlers/main.yml +++ b/ansible/roles/glance/handlers/main.yml @@ -15,6 +15,7 @@ image: "{{ service.image }}" environment: "{{ service.environment }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in glance_api_hosts @@ -41,6 +42,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/glance/tasks/config.yml b/ansible/roles/glance/tasks/config.yml index bca8c573d4..4a94a495bb 100644 --- a/ansible/roles/glance/tasks/config.yml +++ b/ansible/roles/glance/tasks/config.yml @@ -120,6 +120,7 @@ image: "{{ item.value.image }}" environment: "{{ item.value.environment | default(omit) }}" volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" + dimensions: "{{ item.value.dimensions }}" register: check_glance_containers when: - kolla_action != "config" diff --git a/ansible/roles/gnocchi/defaults/main.yml b/ansible/roles/gnocchi/defaults/main.yml index a902032ee9..86c4c8193f 100644 --- a/ansible/roles/gnocchi/defaults/main.yml +++ b/ansible/roles/gnocchi/defaults/main.yml @@ -12,6 +12,7 @@ gnocchi_services: - "/etc/localtime:/etc/localtime:ro" - "gnocchi:/var/lib/gnocchi/" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ gnocchi_api_dimensions }}" gnocchi-metricd: container_name: gnocchi_metricd group: gnocchi-metricd @@ -22,6 +23,7 @@ gnocchi_services: - "/etc/localtime:/etc/localtime:ro" - "gnocchi:/var/lib/gnocchi/" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ gnocchi_metricd_dimensions }}" gnocchi-statsd: container_name: gnocchi_statsd group: gnocchi-statsd @@ -32,6 +34,7 @@ gnocchi_services: - "/etc/localtime:/etc/localtime:ro" - "gnocchi:/var/lib/gnocchi/" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ gnocchi_statsd_dimensions }}" #################### @@ -82,6 +85,10 @@ gnocchi_metricd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ gnocchi_metricd_tag: "{{ gnocchi_tag }}" gnocchi_metricd_image_full: "{{ gnocchi_metricd_image }}:{{ gnocchi_metricd_tag }}" +gnocchi_api_dimensions: "{{ default_container_dimensions }}" +gnocchi_metricd_dimensions: "{{ default_container_dimensions }}" +gnocchi_statsd_dimensions: "{{ default_container_dimensions }}" + #################### # OpenStack #################### diff --git a/ansible/roles/gnocchi/handlers/main.yml b/ansible/roles/gnocchi/handlers/main.yml index e125415aa9..bf90fc3a87 100644 --- a/ansible/roles/gnocchi/handlers/main.yml +++ b/ansible/roles/gnocchi/handlers/main.yml @@ -14,6 +14,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -39,6 +40,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -63,6 +65,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/gnocchi/tasks/config.yml b/ansible/roles/gnocchi/tasks/config.yml index eaeca31d05..6922dfff0c 100644 --- a/ansible/roles/gnocchi/tasks/config.yml +++ b/ansible/roles/gnocchi/tasks/config.yml @@ -108,6 +108,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes }}" + dimensions: "{{ item.value.dimensions }}" register: check_gnocchi_containers when: - kolla_action != "config" diff --git a/ansible/roles/grafana/defaults/main.yml b/ansible/roles/grafana/defaults/main.yml index 4a91446812..759e0356f8 100644 --- a/ansible/roles/grafana/defaults/main.yml +++ b/ansible/roles/grafana/defaults/main.yml @@ -12,6 +12,7 @@ grafana_services: - "/etc/localtime:/etc/localtime:ro" - "grafana:/var/lib/grafana/" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ grafana_dimensions }}" #################### # Database @@ -53,3 +54,5 @@ grafana_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_ grafana_tag: "{{ openstack_release }}" grafana_image_full: "{{ grafana_image }}:{{ grafana_tag }}" grafana_admin_username: "admin" + +grafana_dimensions: "{{ default_container_dimensions }}" diff --git a/ansible/roles/grafana/handlers/main.yml b/ansible/roles/grafana/handlers/main.yml index a39a2ce4d2..a8fb340e1c 100644 --- a/ansible/roles/grafana/handlers/main.yml +++ b/ansible/roles/grafana/handlers/main.yml @@ -13,6 +13,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/grafana/tasks/config.yml b/ansible/roles/grafana/tasks/config.yml index b33168dff3..4dd302822d 100644 --- a/ansible/roles/grafana/tasks/config.yml +++ b/ansible/roles/grafana/tasks/config.yml @@ -106,6 +106,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes }}" + dimensions: "{{ item.value.dimensions }}" register: check_grafana_containers when: - kolla_action != "config" diff --git a/ansible/roles/haproxy/defaults/main.yml b/ansible/roles/haproxy/defaults/main.yml index 88b3adbd55..1dafa84fa3 100644 --- a/ansible/roles/haproxy/defaults/main.yml +++ b/ansible/roles/haproxy/defaults/main.yml @@ -12,6 +12,7 @@ haproxy_services: - "{{ node_config_directory }}/haproxy/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "haproxy_socket:/var/lib/kolla/haproxy/" + dimensions: "{{ haproxy_dimensions }}" keepalived: container_name: keepalived group: haproxy @@ -23,6 +24,7 @@ haproxy_services: - "/etc/localtime:/etc/localtime:ro" - "/lib/modules:/lib/modules:ro" - "haproxy_socket:/var/lib/kolla/haproxy/" + dimensions: "{{ keepalived_dimensions }}" #################### @@ -61,3 +63,6 @@ haproxy_listen_http_extra: [] haproxy_max_connections: 4000 haproxy_processes: 1 haproxy_process_cpu_map: "no" + +haproxy_dimensions: "{{ default_container_dimensions }}" +keepalived_dimensions: "{{ default_container_dimensions }}" diff --git a/ansible/roles/haproxy/handlers/main.yml b/ansible/roles/haproxy/handlers/main.yml index 571c159c64..9ba40a562f 100644 --- a/ansible/roles/haproxy/handlers/main.yml +++ b/ansible/roles/haproxy/handlers/main.yml @@ -13,6 +13,7 @@ image: "{{ service.image }}" privileged: "{{ service.privileged | default(False) }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -38,6 +39,7 @@ image: "{{ service.image }}" privileged: "{{ service.privileged | default(False) }}" volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/haproxy/tasks/config.yml b/ansible/roles/haproxy/tasks/config.yml index 364b5a59f3..d687cf44de 100644 --- a/ansible/roles/haproxy/tasks/config.yml +++ b/ansible/roles/haproxy/tasks/config.yml @@ -101,6 +101,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes }}" + dimensions: "{{ item.value.dimensions }}" privileged: "{{ item.value.privileged | default(False) }}" register: check_haproxy_containers when: diff --git a/ansible/roles/heat/defaults/main.yml b/ansible/roles/heat/defaults/main.yml index d82363d2c5..46506aee0c 100644 --- a/ansible/roles/heat/defaults/main.yml +++ b/ansible/roles/heat/defaults/main.yml @@ -12,6 +12,7 @@ heat_services: - "/etc/localtime:/etc/localtime:ro" - "{{ kolla_dev_repos_directory ~ '/heat/heat:/var/lib/kolla/venv/lib/python2.7/site-packages/heat' if heat_dev_mode | bool else '' }}" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ heat_api_dimensions }}" heat-api-cfn: container_name: heat_api_cfn group: heat-api-cfn @@ -22,6 +23,7 @@ heat_services: - "/etc/localtime:/etc/localtime:ro" - "{{ kolla_dev_repos_directory ~ '/heat/heat:/var/lib/kolla/venv/lib/python2.7/site-packages/heat' if heat_dev_mode | bool else '' }}" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ heat_api_cfn_dimensions }}" heat-engine: container_name: heat_engine group: heat-engine @@ -32,6 +34,7 @@ heat_services: - "/etc/localtime:/etc/localtime:ro" - "{{ kolla_dev_repos_directory ~ '/heat/heat:/var/lib/kolla/venv/lib/python2.7/site-packages/heat' if heat_dev_mode | bool else '' }}" - "kolla_logs:/var/log/kolla/" + dimensions: "{{ heat_engine_dimensions }}" #################### # Database @@ -59,6 +62,10 @@ heat_engine_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ doc heat_engine_tag: "{{ heat_tag }}" heat_engine_image_full: "{{ heat_engine_image }}:{{ heat_engine_tag }}" +heat_api_dimensions: "{{ default_container_dimensions }}" +heat_api_cfn_dimensions: "{{ default_container_dimensions }}" +heat_engine_dimensions: "{{ default_container_dimensions }}" + #################### # OpenStack diff --git a/ansible/roles/heat/handlers/main.yml b/ansible/roles/heat/handlers/main.yml index fe5a5ad529..a28dd2744e 100644 --- a/ansible/roles/heat/handlers/main.yml +++ b/ansible/roles/heat/handlers/main.yml @@ -14,6 +14,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -38,6 +39,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -62,6 +64,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/heat/tasks/config.yml b/ansible/roles/heat/tasks/config.yml index 97d2d501b4..b47f869a34 100644 --- a/ansible/roles/heat/tasks/config.yml +++ b/ansible/roles/heat/tasks/config.yml @@ -102,6 +102,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" + dimensions: "{{ item.value.dimensions }}" register: check_heat_containers when: - kolla_action != "config" diff --git a/ansible/roles/nova/tasks/config.yml b/ansible/roles/nova/tasks/config.yml index d3199e7f7c..679df66f79 100644 --- a/ansible/roles/nova/tasks/config.yml +++ b/ansible/roles/nova/tasks/config.yml @@ -202,6 +202,7 @@ ipc_mode: "{{ item.value.ipc_mode|default(omit) }}" privileged: "{{ item.value.privileged|default(False) }}" volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" + dimensions: "{{ item.value.dimensions }}" register: check_nova_containers when: - kolla_action != "config" diff --git a/doc/source/reference/resource-constraints.rst b/doc/source/reference/resource-constraints.rst index 875db5bd83..a70c4c6943 100644 --- a/doc/source/reference/resource-constraints.rst +++ b/doc/source/reference/resource-constraints.rst @@ -8,12 +8,7 @@ Overview ~~~~~~~~ Since the Rocky release it is possible to restrict -the resource usage of deployed containers. -The following components support this feature: - -* Nova - -In Kolla Ansible, +the resource usage of deployed containers. In Kolla Ansible, container resources to be constrained are referred to as dimensions. The `Docker documentation `__ @@ -39,7 +34,42 @@ Pre-deployment Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dimensions are defined as a mapping from a Docker resource name -(e.g. ``cpu_period``) to a string constraint value. + +.. list-table:: Resource Constraints + :widths: 25 25 25 + :header-rows: 1 + + * - Resource + - Data Type + - Default Value + * - cpu_period + - Integer + - 0 + * - blkio_weight + - Integer + - 0 + * - cpu_quota + - Integer + - 0 + * - cpu_shares + - Integer + - 0 + * - mem_limit + - Integer + - 0 + * - memswap_limit + - Integer + - 0 + * - mem_reservation + - Integer + - 0 + * - cpuset_cpus + - String + - ''(Empty String) + * - cpuset_mems + - String + - ''(Empty String) + The variable ``default_container_dimensions`` sets the default dimensions for all supported containers, and by default these are unconstrained. diff --git a/tests/test_kolla_docker.py b/tests/test_kolla_docker.py index 7029856eb0..d2e7a9de72 100644 --- a/tests/test_kolla_docker.py +++ b/tests/test_kolla_docker.py @@ -810,6 +810,82 @@ class TestAttrComp(base.BaseTestCase): self.dw = get_DockerWorker({'state': 'running'}) self.assertFalse(self.dw.compare_container_state(container_info)) + def test_compare_dimensions_pos(self): + self.fake_data['params']['dimensions'] = { + 'blkio_weight': 10, 'mem_limit': 30} + container_info = dict() + container_info['HostConfig'] = { + 'CpuPeriod': 0, 'KernelMemory': 0, 'Memory': 0, 'CpuQuota': 0, + 'CpusetCpus': '', 'CpuShares': 0, 'BlkioWeight': 0, + 'CpusetMems': '', 'MemorySwap': 0, 'MemoryReservation': 0} + self.dw = get_DockerWorker(self.fake_data['params']) + self.assertTrue(self.dw.compare_dimensions(container_info)) + + def test_compare_dimensions_neg(self): + self.fake_data['params']['dimensions'] = { + 'blkio_weight': 10} + container_info = dict() + container_info['HostConfig'] = { + 'CpuPeriod': 0, 'KernelMemory': 0, 'Memory': 0, 'CpuQuota': 0, + 'CpusetCpus': '', 'CpuShares': 0, 'BlkioWeight': 10, + 'CpusetMems': '', 'MemorySwap': 0, 'MemoryReservation': 0} + self.dw = get_DockerWorker(self.fake_data['params']) + self.assertFalse(self.dw.compare_dimensions(container_info)) + + def test_compare_wrong_dimensions(self): + self.fake_data['params']['dimensions'] = { + 'blki_weight': 0} + container_info = dict() + container_info['HostConfig'] = { + 'CpuPeriod': 0, 'KernelMemory': 0, 'Memory': 0, 'CpuQuota': 0, + 'CpusetCpus': '', 'CpuShares': 0, 'BlkioWeight': 0, + 'CpusetMems': '', 'MemorySwap': 0, 'MemoryReservation': 0} + self.dw = get_DockerWorker(self.fake_data['params']) + self.dw.compare_dimensions(container_info) + self.dw.module.exit_json.assert_called_once_with( + failed=True, msg=repr("Unsupported dimensions"), + unsupported_dimensions=set(['blki_weight'])) + + def test_compare_empty_dimensions(self): + self.fake_data['params']['dimensions'] = dict() + container_info = dict() + container_info['HostConfig'] = { + 'CpuPeriod': 0, 'KernelMemory': 0, 'Memory': 0, 'CpuQuota': 0, + 'CpusetCpus': '1', 'CpuShares': 0, 'BlkioWeight': 0, + 'CpusetMems': '', 'MemorySwap': 0, 'MemoryReservation': 0} + self.dw = get_DockerWorker(self.fake_data['params']) + self.assertTrue(self.dw.compare_dimensions(container_info)) + + def test_compare_dimensions_removed_and_changed(self): + self.fake_data['params']['dimensions'] = { + 'mem_reservation': 10} + container_info = dict() + # Here mem_limit and mem_reservation are already present + # Now we are updating only 'mem_reservation'. + # Ideally it should return True stating that the docker + # dimensions have been changed. + container_info['HostConfig'] = { + 'CpuPeriod': 0, 'KernelMemory': 0, 'Memory': 10, 'CpuQuota': 0, + 'CpusetCpus': '', 'CpuShares': 0, 'BlkioWeight': 0, + 'CpusetMems': '', 'MemorySwap': 0, 'MemoryReservation': 10} + self.dw = get_DockerWorker(self.fake_data['params']) + self.assertTrue(self.dw.compare_dimensions(container_info)) + + def test_compare_dimensions_explicit_default(self): + self.fake_data['params']['dimensions'] = { + 'mem_reservation': 0} + container_info = dict() + # Here mem_limit and mem_reservation are already present + # Now we are updating only 'mem_reservation'. + # Ideally it should return True stating that the docker + # dimensions have been changed. + container_info['HostConfig'] = { + 'CpuPeriod': 0, 'KernelMemory': 0, 'Memory': 0, 'CpuQuota': 0, + 'CpusetCpus': '', 'CpuShares': 0, 'BlkioWeight': 0, + 'CpusetMems': '', 'MemorySwap': 0, 'MemoryReservation': 0} + self.dw = get_DockerWorker(self.fake_data['params']) + self.assertFalse(self.dw.compare_dimensions(container_info)) + def test_compare_container_state_pos(self): container_info = {'State': dict(Status='running')} self.dw = get_DockerWorker({'state': 'exited'})