Skip to content

Commit 4cab35b

Browse files
committed
Change Bifrost Python upper-constraints source
Users can override the upper-constraints.txt by setting the source of openstack-base in kolla-build.conf. However, bifrost-base Dockerfile so far doesn't pass overridden upper-constraints file to Bifrost install playbook resulting the playbook not acknowledging it and just use upstream one. This change sets the source of Bifrost upper-constraints to use upper-constraints of openstack-base for consistency among all Kolla images With this, change the environment variable UPPER_CONSTRAINTS_FILE is only affecting kolla-toolbox image. Therefore, moved UPPER_CONSTRATINS_FILE variable example to the ``kolla_toolbox_pip_conf`` block of kolla-toolbox Dockerfile. Additionally, updated 'Python packages build options' section of documentation to represent latest method of changing Python package related options (including this change). Change-Id: I0a9c782ca1177ef84e4323cb1e5bfac0fb3f383c
1 parent 68fa7d3 commit 4cab35b

File tree

5 files changed

+83
-7
lines changed

5 files changed

+83
-7
lines changed

doc/source/admin/image-building.rst

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,69 @@ Python packages build options
320320

321321
The block ``base_pip_conf`` in the ``base`` Dockerfile can be used to provide
322322
the PyPI build customisation options via the standard environment variables
323-
like ``PIP_INDEX_URL``, ``PIP_TRUSTED_HOST``, etc. Also here can be provided
324-
the standard environment variable ``UPPER_CONSTRAINTS_FILE`` used for building
325-
the ``bifrost_deploy`` container when PyPI upper-constraints needs to be
326-
overridden. Also this variable would be used in the ``kolla-toolbox`` if
327-
provided instead of the defaults.
323+
like ``PIP_INDEX_URL``, ``PIP_TRUSTED_HOST``, etc.
324+
325+
To override PYPI upper-constraints of all OpenStack images, you can
326+
define the source location of openstack-base. in ``kolla-build.conf``.
327+
328+
Upstream repository of `openstack-base (requirements) <https://opendev.org/openstack/requirements>`__
329+
has a source of
330+
`upper constraints file <https://opendev.org/openstack/requirements/src/branch/master/upper-constraints.txt>`__.
331+
332+
Make a fork or clone the repository then customise ``upper-constraints.txt``
333+
and define the location of ``openstack-base`` in ``kolla_build.conf``.
334+
335+
.. path /etc/kolla/kolla-build.conf
336+
.. code-block:: ini
337+
338+
# These examples use upstream openstack-base as a demonstration
339+
# To use custom openstack-base, make changes accordingly
340+
341+
# Using git source
342+
[openstack-base]
343+
type = git
344+
location = https://opendev.org/openstack/requirements
345+
reference = master
346+
347+
# Using URL source
348+
[openstack-base]
349+
type = url
350+
location = https://tarballs.opendev.org/openstack/requirements/requirements-master.tar.gz
351+
352+
# Using local source
353+
[openstack-base]
354+
type = local
355+
location = /home/kolla/src/requirements
356+
357+
To remove or change the version of specific Python packages in
358+
``openstack-base`` upper-constraints, you can use the block
359+
``openstack_base_override_upper_constraints`` in your template file,
360+
for example, ``template-overrides.j2``:
361+
362+
.. code-block:: jinja
363+
364+
{% block openstack_base_override_upper_constraints %}
365+
RUN {{ macros.upper_constraints_version_change("sqlparse", "0.4.4", "0.5.0") }}
366+
RUN {{ macros.upper_constraints_remove("reno") }}
367+
{% endblock %}
368+
369+
``kolla-toolbox`` image needs different approach as it does not uses
370+
``openstack-base`` as a base image.
371+
A variable ``UPPER_CONSTRAINTS_FILE`` is set in the
372+
Dockerfile of ``kolla-toolbox``.
373+
To change variable, add the following contents to the
374+
``kolla_toolbox_pip_conf`` block in your template file, for example,
375+
``template-overrides.j2``:
376+
377+
.. code-block:: jinja
378+
379+
{% block kolla_toolbox_pip_conf %}
380+
ENV UPPER_CONSTRAINTS_FILE=https://releases.openstack.org/constraints/upper/master
381+
{% endblock %}
382+
383+
.. note::
384+
385+
``UPPER_CONSTRAINTS_FILE`` must be a valid URL to the file
328386

329387
Plugin functionality
330388
--------------------

docker/base/Dockerfile.j2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ RUN touch /usr/local/bin/kolla_extend_start \
379379
# the variables like PIP_INDEX_URL, PIP_EXTRA_INDEX_URL, PIP_TRUSTED_HOST etc. should be defined here.
380380
# ENV PIP_INDEX_URL=https://pypi.python.org/simple
381381
# ENV PIP_TRUSTED_HOST=pypi.python.org
382-
# ENV UPPER_CONSTRAINTS_FILE=https://releases.openstack.org/constraints/upper/{{ openstack_release }}
383382
{% endblock %}
384383

385384
{% block base_footer %}{% endblock %}

docker/bifrost/bifrost-base/Dockerfile.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ RUN echo " " && \
4545
$VENV/bin/ansible-galaxy collection install -r /bifrost/ansible-collections-requirements.yml && \
4646
$VENV/bin/ansible-playbook -vvvv -i /bifrost/playbooks/inventory/target \
4747
/bifrost/playbooks/install.yaml \
48+
-e upper_constraints_file="/requirements/upper-constraints.txt" \
4849
-e git_branch={{ openstack_branch_slashed }} \
4950
-e ipa_upstream_release={{ openstack_branch }} \
5051
-e enable_inspector=true \

docker/kolla-toolbox/Dockerfile.j2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,13 @@ RUN cd /usr/bin && \
7878
ln -s python3.12 python3
7979
{% endif %}
8080

81+
{% block kolla_toolbox_pip_conf %}
82+
ENV UPPER_CONSTRAINTS_FILE=https://releases.openstack.org/constraints/upper/{{ openstack_release }}
83+
{% endblock %}
84+
8185
{% block kolla_toolbox_upper_constraints %}
8286
RUN mkdir -p /requirements \
83-
&& curl -o /requirements/upper-constraints.txt ${UPPER_CONSTRAINTS_FILE:-https://releases.openstack.org/constraints/upper/{{ openstack_release }}} \
87+
&& curl -o /requirements/upper-constraints.txt $UPPER_CONSTRAINTS_FILE \
8488
&& {{ macros.upper_constraints_remove("openstacksdk") }} \
8589
&& python3 -m venv --system-site-packages {{ venv_path }} \
8690
&& KOLLA_DISTRO_PYTHON_VERSION=$(/usr/bin/python3 -c "import sys; print('{}.{}'.format(sys.version_info.major, sys.version_info.minor))") \
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
features:
3+
- |
4+
Updated the contents of Python package options in documentation to reflect
5+
latest customisation methods.
6+
upgrade:
7+
- |
8+
The use of ``UPPER_CONSTRAINTS_FILE`` environment variable was moved from
9+
``base_pip_conf`` block in base Dockerfile to ``kolla_toolbox_pip_conf``
10+
block in kolla-toolbox Dockerfile as the environment variable now only
11+
affects Kolla-toolbox build.
12+
Bifrost python upper-constraints now follows openstack-base's
13+
python upper-constraints instead of ``UPPER_CONSTRAINTS_FILE`` environment
14+
variable.

0 commit comments

Comments
 (0)