docker: implement macros to alter upper-constraints.txt

upper_constraints_remove() macro allows to remove line
upper_constraints_version_change() allows to change versions

This way we have cleaner way to alter u-c in those images which need it.

Change-Id: I8fc354b8aa4d03fcd3ecfb9cbfe75de67492a0e3
This commit is contained in:
Marcin Juszkiewicz 2023-03-27 16:55:04 +02:00
parent 2b0a5f684b
commit 19e40f1608
8 changed files with 24 additions and 6 deletions

View File

@ -25,7 +25,7 @@ COPY extend_start.sh /usr/local/bin/kolla_extend_start
# NOTE(egonzalez): Remove ceilometer from constraint or will fail.
RUN ln -s ceilometer-base-source/* ceilometer \
&& sed -i 's|^ceilometer===.*$||g' requirements/upper-constraints.txt \
&& {{ macros.upper_constraints_remove("ceilometer") }} \
&& {{ macros.install_pip(ceilometer_base_pip_packages | customizable("pip_packages")) }} \
&& mkdir -p /etc/ceilometer \
&& cp -r /ceilometer/etc/ceilometer/* /etc/ceilometer/ \

View File

@ -47,7 +47,7 @@ COPY extend_start.sh /usr/local/bin/kolla_extend_start
# NOTE(hrw): to install horizon from unpacked sources we cannot have it in upper-constraints.txt
RUN ln -s horizon-source/* horizon \
&& sed -i /^horizon=/d /requirements/upper-constraints.txt \
&& {{ macros.upper_constraints_remove("horizon") }} \
&& {{ macros.install_pip(horizon_pip_packages | customizable("pip_packages")) }} \
&& mkdir -p /etc/openstack-dashboard \
&& cp -r /horizon/openstack_dashboard/conf/* /etc/openstack-dashboard/ \

View File

@ -60,7 +60,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
{% block kolla_toolbox_upper_constraints %}
RUN mkdir -p /requirements \
&& curl -o /requirements/upper-constraints.txt ${UPPER_CONSTRAINTS_FILE:-https://releases.openstack.org/constraints/upper/{{ openstack_release }}} \
&& sed -e "/^openstacksdk/d" -i /requirements/upper-constraints.txt \
&& {{ macros.upper_constraints_remove("openstacksdk") }} \
&& {{ macros.install_pip(kolla_toolbox_pip_virtualenv_packages | customizable("pip_virtualenv_packages")) }} \
&& python3 -m venv --system-site-packages {{ virtualenv_path }}
{% endblock %}

View File

@ -20,7 +20,7 @@ COPY extend_start.sh /usr/local/bin/kolla_extend_start
# NOTE(Jeffrey4l): remove kuryr-lib constraint in upper-constraints.txt file.
# Otherwise, it will be failed.
RUN ln -s kuryr-base-source/* kuryr-base \
&& sed -i 's|^kuryr-lib===.*$||g' requirements/upper-constraints.txt \
&& {{ macros.upper_constraints_remove("kuryr-lib") }} \
&& {{ macros.install_pip(kuryr_base_pip_packages | customizable("pip_packages")) }} \
&& mkdir -p /etc/kuryr \
&& chmod 644 /usr/local/bin/kolla_extend_start

View File

@ -76,3 +76,12 @@ RUN usermod --append --home {{ homedir }} --groups kolla {{ name }} \
{{ handle_repos(repos, 'disable') }}
{% endmacro %}
{% macro upper_constraints_remove(package_name) -%}
sed -e "/^{{ package_name }}===/d" -i requirements/upper-constraints.txt
{%- endmacro %}
{# NOTE(hrw): we change to "==" to allow for "21.*" syntax #}
{% macro upper_constraints_version_change(package_name, from, to) -%}
sed -e "s/^{{package_name}}==={{ from }}/{{package_name}}=={{ to }}/g" -i requirements/upper-constraints.txt
{%- endmacro %}

View File

@ -21,7 +21,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
] %}
{# NOTE(hrw): pyzmq 20 fails to build while 19.* and 21.* build fine. #}
RUN sed -e "s/^pyzmq===20.0.0/pyzmq==21.*/g" -i /requirements/upper-constraints.txt \
RUN {{ macros.upper_constraints_version_change("pyzmq", "20.0.0", "21.*") }} \
&& {{ macros.install_pip(neutron_mlnx_agent_pip_packages | customizable("pip_packages")) }}
{% block neutron_mlnx_agent_footer %}{% endblock %}

View File

@ -190,7 +190,7 @@ RUN ln -s openstack-base-source/* /requirements \
is usually newer than UC entry and older version would get installed
in venv (see https://launchpad.net/bugs/1961874).
#}
&& sed -i /^ovs=/d /requirements/upper-constraints.txt \
&& {{ macros.upper_constraints_remove("ovs") }} \
&& mkdir -p /var/lib/kolla \
&& python3 -m venv --system-site-packages /var/lib/kolla/venv

View File

@ -0,0 +1,9 @@
---
features:
- |
Added two macros to manipulate "upper-constraints.txt" file:
- upper_constraints_remove()
- upper_constraints_version_change()
First one allows to remove not wanted constraint, second is for version
changes.