Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Only build venvs for services which are deployed
Browse files Browse the repository at this point in the history
The current repo build process builds venvs for all OpenStack services,
regardless of whether they're actually going to be used.

To reduce the repo build time, this patch will only build venvs for
OpenStack services where there is one or more members in the service
inventory group.

Change-Id: If966de6f2b8d972e9addc3385b8de5c13a986cc1
  • Loading branch information
Jesse Pretorius committed Jul 20, 2016
1 parent ec7bffa commit 37eb0de
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions defaults/main.yml
Expand Up @@ -26,6 +26,9 @@ repo_build_pool_dir: "/var/www/repo/pools"

repo_build_release_tag: "untagged"

# Toggle whether venvs should be built selectively or not
repo_build_venv_selective: yes

# Optionally set this to change the default index from pypi to an alternative
#repo_build_pip_default_index: "https://pypi.python.org/simple"

Expand Down
8 changes: 8 additions & 0 deletions releasenotes/notes/selective-venv-build-dd9f0e40cd1cc076.yaml
@@ -0,0 +1,8 @@
---
features:
- The repo build process now selectively builds venvs based on
whether each OpenStack service group has any hosts in it. If
there are no hosts in the group, the venv will not be built.
This behaviour can be optionally changed to force all venvs
to be built by setting ``repo_build_venv_selective`` to
``yes``.
3 changes: 2 additions & 1 deletion templates/op-venv-script.sh.j2
Expand Up @@ -47,7 +47,8 @@ function venv_create {
# purposes the group data will be rendered as a comment.
{% set os_group = {} %}
{% for key, value in local_packages.results.0.item.role_packages.items() %}
{% if "os_" in key %}
{% set _host_group = key | replace('os_', '') + '_all' %}
{% if ("os_" in key) and (not repo_build_venv_selective | bool) or ((groups[_host_group] is defined) and (groups[_host_group] | length > 0)) %}
# venv to build {{ key }}
# * packages within the {{ key }} venv: {{ value }}
{% set _ = os_group.update({key: value}) %}
Expand Down
4 changes: 4 additions & 0 deletions tests/inventory
Expand Up @@ -7,3 +7,7 @@ container1

[all_containers:children]
repo_all

# This is here to validate the venv build inclusion
[keystone_all]
container1
10 changes: 10 additions & 0 deletions tests/test-repo-build.yml
Expand Up @@ -39,5 +39,15 @@
roles:
- "repo_server"
- "{{ rolename | basename }}"
post_tasks:
- name: List the files in the venv folder
command: ls -1 /var/www/repo/venvs/{{ repo_build_release_tag }}/{{ ansible_distribution | lower }}/
register: venv_folder_content
- name: Ensure that the keystone venv is present
assert:
that: "'keystone-{{ repo_build_release_tag }}.tgz' in venv_folder_content.stdout"
- name: Ensure that the nova venv is NOT present
assert:
that: "'nova-{{ repo_build_release_tag }}.tgz' not in venv_folder_content.stdout"
vars_files:
- test-vars.yml
1 change: 1 addition & 0 deletions tests/test-vars.yml
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.

openstack_release: testing
repo_build_release_tag: "{{ openstack_release }}"
galera_client_drop_config_file: false
local_packages:
results:
Expand Down

0 comments on commit 37eb0de

Please sign in to comment.