diff --git a/docker/ceilometer/ceilometer-base/Dockerfile.j2 b/docker/ceilometer/ceilometer-base/Dockerfile.j2 index cbae0fe38b..93b7f6d414 100644 --- a/docker/ceilometer/ceilometer-base/Dockerfile.j2 +++ b/docker/ceilometer/ceilometer-base/Dockerfile.j2 @@ -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/ \ diff --git a/docker/horizon/Dockerfile.j2 b/docker/horizon/Dockerfile.j2 index b2b6ab9b33..70f64548f5 100644 --- a/docker/horizon/Dockerfile.j2 +++ b/docker/horizon/Dockerfile.j2 @@ -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/ \ diff --git a/docker/kolla-toolbox/Dockerfile.j2 b/docker/kolla-toolbox/Dockerfile.j2 index 073cc8f026..118cdf1f24 100644 --- a/docker/kolla-toolbox/Dockerfile.j2 +++ b/docker/kolla-toolbox/Dockerfile.j2 @@ -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 %} diff --git a/docker/kuryr/kuryr-base/Dockerfile.j2 b/docker/kuryr/kuryr-base/Dockerfile.j2 index 75cafdf0be..71ae72fc9c 100644 --- a/docker/kuryr/kuryr-base/Dockerfile.j2 +++ b/docker/kuryr/kuryr-base/Dockerfile.j2 @@ -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 diff --git a/docker/macros.j2 b/docker/macros.j2 index 20bf21aa3d..1c89fee9d7 100644 --- a/docker/macros.j2 +++ b/docker/macros.j2 @@ -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 %} diff --git a/docker/neutron/neutron-mlnx-agent/Dockerfile.j2 b/docker/neutron/neutron-mlnx-agent/Dockerfile.j2 index 3b5aadaa20..d3a5d8a65c 100644 --- a/docker/neutron/neutron-mlnx-agent/Dockerfile.j2 +++ b/docker/neutron/neutron-mlnx-agent/Dockerfile.j2 @@ -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 %} diff --git a/docker/openstack-base/Dockerfile.j2 b/docker/openstack-base/Dockerfile.j2 index f157d8ff73..fd974314d6 100644 --- a/docker/openstack-base/Dockerfile.j2 +++ b/docker/openstack-base/Dockerfile.j2 @@ -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 diff --git a/releasenotes/notes/upper-constraints-macros-21315dc1c1933e78.yaml b/releasenotes/notes/upper-constraints-macros-21315dc1c1933e78.yaml new file mode 100644 index 0000000000..2129ebd429 --- /dev/null +++ b/releasenotes/notes/upper-constraints-macros-21315dc1c1933e78.yaml @@ -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.