Improve pip install process for offline deployment.

* "Use distribution-provided pip"
    * "Use python's pip module invocation method"
    * "Install pip earlier in order to avoid multiple installation"
    * "Remove pip_version variable requirement and call"

(cherry picked from commit b93c40a363)

- fixed source type builds.
- in openstack-base: install virtualenv using upper-constraints
  (just like in kolla-toolbox)

Co-authored-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Co-authored-by: Radosław Piliszek <radoslaw.piliszek@gmail.com>

Depends-on: https://review.opendev.org/c/openstack/kolla-ansible/+/772198

Closes-bug: #1893204
Change-Id: Id0e738044a1931f9d611a7281a48ea4a593f1cf1
This commit is contained in:
Gaël THEROND (Fl1nt) 2020-09-17 14:38:21 +02:00 committed by Radosław Piliszek
parent 6beff0cfc9
commit 278893ef1d
7 changed files with 14 additions and 35 deletions

View File

@ -337,11 +337,13 @@ RUN yum-config-manager --enable rhel-7-server-optional-rpms \
] %}
{% if distro_python_version.startswith('3') %}
{% set base_centos_binary_packages = base_centos_binary_packages + [
'python3'
'python3',
'python3-pip'
] %}
{% else %}
{% set base_centos_binary_packages = base_centos_binary_packages + [
'python'
'python',
'python-pip'
] %}
{% endif %}
{% if distro_package_manager == 'dnf' %}
@ -376,11 +378,13 @@ RUN yum-config-manager --enable rhel-7-server-optional-rpms \
] %}
{% if distro_python_version.startswith('3') %}
{% set base_centos_source_packages = base_centos_source_packages + [
'python3'
'python3',
'python3-pip'
] %}
{% else %}
{% set base_centos_source_packages = base_centos_source_packages + [
'python'
'python',
'python-pip'
] %}
{% endif %}
{% if distro_package_manager == 'dnf' %}
@ -455,6 +459,7 @@ COPY apt_preferences /etc/apt/preferences.d/kolla-custom
'open-iscsi',
'procps',
'python3',
'python3-pip',
'socat',
'sudo',
'tgt']

View File

@ -26,7 +26,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
'elasticsearch-curator'
] %}
RUN {{ macros.install_pip(elasticsearch_curator_pip_packages | customizable("pip_packages"), constraints=false, pip_version="pip3") }} \
RUN {{ macros.install_pip(elasticsearch_curator_pip_packages | customizable("pip_packages"), constraints=false) }} \
&& mkdir -p /etc/elasticsearch-curator \
&& chown -R elasticsearch: /etc/elasticsearch-curator

View File

@ -53,7 +53,7 @@ RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf \
] %}
{{ macros.install_packages(gnocchi_base_packages | customizable("packages")) }}
RUN {{ macros.install_pip(gnocchi_base_pip_packages | customizable("pip_packages"), constraints=false, pip_version="pip3") }} \
RUN {{ macros.install_pip(gnocchi_base_pip_packages | customizable("pip_packages"), constraints=false) }} \
&& truncate -s 0 /etc/apache2/ports.conf
{% endif %}

View File

@ -28,10 +28,6 @@ ENV helm_version=2.3.0 \
{% endif %}
{{ macros.install_packages(helm_repo_packages | customizable("packages")) }}
{% block helm_repository_source_install_python_pip %}
{{ macros.get_pip() }}
{% endblock %}
{% set helm_repository_pip_packages = [
'pyyaml'
] %}

View File

@ -70,10 +70,6 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
{% endif %}
{{ macros.install_packages(kolla_toolbox_packages | customizable("packages")) }}
{% block kolla_toolbox_source_install_python_pip %}
{{ macros.get_pip() }}
{% endblock %}
{% set kolla_toolbox_pip_virtualenv_packages = [
'virtualenv'
] %}

View File

@ -36,23 +36,9 @@
{% endif %}
{%- endmacro %}
{% macro get_pip() %}
{% if distro_python_version == '2.7' %}
{% set python='python' %}
{% else %}
{% set python='python3' %}
{% endif %}
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& {{python}} get-pip.py \
&& rm get-pip.py
{% endmacro %}
{% macro install_pip(packages, constraints = true, pip_version = pip) %}
{% macro install_pip(packages, constraints = true) %}
{%- if packages is sequence and packages|length > 0 -%}
{%- if not pip_version -%}
{%- set pip_version = 'pip' -%}
{%- endif -%}
{{ pip_version }} --no-cache-dir install --upgrade{{ ' ' }}
python{{ distro_python_version }} -m pip --no-cache-dir install --upgrade{{ ' ' }}
{%- if constraints %}-c /requirements/upper-constraints.txt {% endif -%}
{{ packages | join(' ') }}
{%- else -%}

View File

@ -276,10 +276,6 @@ ENV DEBIAN_FRONTEND noninteractive
{{ macros.install_packages(openstack_base_packages | customizable("packages")) }}
{% block source_install_python_pip %}
{{ macros.get_pip() }}
{% endblock %}
{% set openstack_base_pip_packages = [
'Babel',
'Mako',
@ -409,7 +405,7 @@ ENV DEBIAN_FRONTEND noninteractive
ADD openstack-base-archive /openstack-base-source
RUN ln -s openstack-base-source/* /requirements \
&& mkdir -p /var/lib/kolla \
&& {{ macros.install_pip(['virtualenv'], constraints = false)}} \
&& {{ macros.install_pip(['virtualenv'])}} \
&& virtualenv --system-site-packages /var/lib/kolla/venv
ENV PATH /var/lib/kolla/venv/bin:$PATH