From 2e438918384447d52c958d61b9a377c375ec932b Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Tue, 31 Jan 2017 17:55:12 +0100 Subject: [PATCH] Support non-x86 architectures (aarch64, ppc64le) Based on ppc64le changes by Sajauddin Mohammad [1] 1. https://review.openstack.org/#/c/423239/6 Tested with centos, debian, ubuntu on aarch64 and ppc64le. Partially-Implements: blueprint multiarch-and-arm64-containers Change-Id: If0ccc58d436b2468cd477c222ebc2fe0073206e9 --- docker/base/Dockerfile.j2 | 103 ++++++++++++++---- docker/base/aarch64-cbs.repo | 26 +++++ docker/base/sources.list.ubuntu | 2 + docker/base/sources.list.ubuntu.aarch64 | 11 ++ docker/base/sources.list.ubuntu.ppc64le | 14 +++ kolla/common/config.py | 29 ++++- kolla/image/build.py | 3 + ...-sources.list-change-65bb0f936b0ec95b.yaml | 7 ++ 8 files changed, 165 insertions(+), 30 deletions(-) create mode 100644 docker/base/aarch64-cbs.repo create mode 100644 docker/base/sources.list.ubuntu.aarch64 create mode 100644 docker/base/sources.list.ubuntu.ppc64le create mode 100644 releasenotes/notes/ubuntu-sources.list-change-65bb0f936b0ec95b.yaml diff --git a/docker/base/Dockerfile.j2 b/docker/base/Dockerfile.j2 index ee19c3a26a..30a3150f07 100644 --- a/docker/base/Dockerfile.j2 +++ b/docker/base/Dockerfile.j2 @@ -42,33 +42,52 @@ RUN CURRENT_DISTRO_RELEASE=$(awk '{match($0, /[0-9]+/,version)}END{print version #### BEGIN REPO ENABLEMENT {% set base_yum_repo_files = [ - 'elasticsearch.repo', - 'grafana.repo', - 'influxdb.repo', - 'kibana.yum.repo', - 'MariaDB.repo', - 'td.repo', - 'zookeeper.repo' ] %} + +{% set base_yum_url_packages = [ +] %} + +{% set base_yum_repo_keys = [ +] %} + +{% if base_arch == 'aarch64' %} + {% set base_yum_repo_files = [ + 'aarch64-cbs.repo' + ] %} + +{% elif base_arch == 'x86_64' %} + {% set base_yum_repo_files = [ + 'elasticsearch.repo', + 'grafana.repo', + 'influxdb.repo', + 'kibana.yum.repo', + 'MariaDB.repo', + 'td.repo', + 'zookeeper.repo' + ] %} + + {% set base_yum_url_packages = [ + 'http://repo.percona.com/release/7/RPMS/x86_64/percona-release-0.1-4.noarch.rpm' + ] %} + + {% set base_yum_repo_keys = [ + 'http://yum.mariadb.org/RPM-GPG-KEY-MariaDB', + '/etc/pki/rpm-gpg/RPM-GPG-KEY-Percona', + 'https://packages.elastic.co/GPG-KEY-elasticsearch', + 'https://repos.influxdata.com/influxdb.key', + 'https://packagecloud.io/gpg.key', + 'https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana', + 'https://packages.treasuredata.com/GPG-KEY-td-agent' + ] %} +{% endif %} + {%- for repo_file in base_yum_repo_files | customizable('yum_repo_files') %} COPY {{ repo_file }} /etc/yum.repos.d/{{ repo_file }} {%- endfor %} -{% set base_yum_url_packages = [ - 'http://repo.percona.com/release/7/RPMS/x86_64/percona-release-0.1-4.noarch.rpm' -] %} {{ macros.install_packages(base_yum_url_packages | customizable("yum_url_packages")) }} -{% set base_yum_repo_keys = [ - 'http://yum.mariadb.org/RPM-GPG-KEY-MariaDB', - '/etc/pki/rpm-gpg/RPM-GPG-KEY-Percona ', - 'https://packages.elastic.co/GPG-KEY-elasticsearch', - 'https://repos.influxdata.com/influxdb.key', - 'https://packagecloud.io/gpg.key', - 'https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana', - 'https://packages.treasuredata.com/GPG-KEY-td-agent' -] %} -{%- for key in base_yum_repo_keys | customizable('yum_repo_keys') %} +{% for key in base_yum_repo_keys | customizable('yum_repo_keys') %} {%- if loop.first %}RUN {% else %} && {% endif -%} rpm --import {{ key }} {%- if not loop.last %} \{% endif %} @@ -100,17 +119,25 @@ RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 {% endblock %} {% set base_centos_yum_repo_keys = [ - '/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage', - '/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization' ] %} {% set base_centos_yum_repo_packages = [ - 'centos-release-ceph-jewel', - 'centos-release-qemu-ev', 'epel-release', 'yum-plugin-priorities' ] %} +{% if base_arch == 'x86_64' %} + {% set base_centos_yum_repo_keys = base_centos_yum_repo_keys + [ + '/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage', + '/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization' + ] %} + + {% set base_centos_yum_repo_packages = base_centos_yum_repo_packages + [ + 'centos-release-ceph-jewel', + 'centos-release-qemu-ev' + ] %} +{% endif %} + {{ macros.install_packages(base_centos_yum_repo_packages | customizable("centos_yum_repo_packages")) }} {% for key in base_centos_yum_repo_keys | customizable('centos_yum_repo_keys') %} {%- if loop.first %}RUN {% else %} && {% endif -%} @@ -171,6 +198,12 @@ RUN yum -y install \ {# We are back to the basic if conditional here which is: if base_distro in ['centos', 'oraclelinux', 'rhel'] #} + +{% set base_compiler_packages = [ + 'gcc', + 'glibc-static' +] %} + {% block base_redhat_binary_versionlock %}{% endblock %} {% if install_type == 'binary' %} {% set base_centos_binary_packages = [ @@ -228,7 +261,11 @@ RUN apt-get update \ {% endblock %} {% block base_ubuntu_package_sources_list %} +{% if base_distro == 'debian' or ( base_distro == 'ubuntu' and base_arch == 'x86_64' ) %} COPY sources.list.{{ base_distro }} /etc/apt/sources.list +{% else %} +COPY sources.list.{{ base_distro }}.{{ base_arch }} /etc/apt/sources.list +{% endif %} {% endblock %} {% block base_ubuntu_package_apt_preferences %} @@ -248,6 +285,9 @@ COPY apt_preferences.{{ base_distro }} /etc/apt/preferences 'sudo', 'tgt'] %} +{% set base_compiler_packages = [ + 'build-essential' +] %} {% if base_distro == 'ubuntu' %} {# 05CE15085FC09D18E99EFB22684A14CF2582E0C5 -- InfluxDB Packaging Service #} @@ -322,8 +362,23 @@ COPY sudoers /etc/sudoers COPY curlrc /root/.curlrc {% block dumb_init_installation %} + +{% if base_arch == 'x86_64' %} + RUN curl -sSL https://github.com/Yelp/dumb-init/releases/download/v1.1.3/dumb-init_1.1.3_amd64 -o /usr/local/bin/dumb-init \ && chmod +x /usr/local/bin/dumb-init + +{% else %} + +{{ macros.install_packages(base_compiler_packages) }} + +RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \ + && python get-pip.py \ + && rm get-pip.py \ + && pip --no-cache-dir install --prefix='/usr/local' dumb-init==1.1.3 \ + && chmod +x /usr/local/bin/dumb-init + +{% endif %} {% endblock %} RUN touch /usr/local/bin/kolla_extend_start \ diff --git a/docker/base/aarch64-cbs.repo b/docker/base/aarch64-cbs.repo new file mode 100644 index 0000000000..4a60b4bb3c --- /dev/null +++ b/docker/base/aarch64-cbs.repo @@ -0,0 +1,26 @@ +[aarch64-ceph-jewel] +name=CentOS Storage SIG repo with Ceph jewel +baseurl=https://buildlogs.centos.org/centos/7/storage/aarch64/ceph-jewel/ +enabled=1 +gpgcheck=0 + +# those three below are from delorean-deps.repo +# we are in a middle of sorting that out at RDO + +[aarch64-kvm] +name=CentOS Virt SIG repo +baseurl=https://buildlogs.centos.org/centos/7/virt/aarch64/kvm-common/ +enabled=1 +gpgcheck=0 + +[delorean-pike-testing] +name=dlrn-pike-testing +baseurl=https://buildlogs.centos.org/centos/7/cloud/$basearch/openstack-pike/ +enabled=1 +gpgcheck=0 + +[delorean-pike-pending] +name=dlrn-pike-pending +baseurl=https://cbs.centos.org/repos/cloud7-openstack-common-pending/$basearch/os/ +gpgcheck=0 +enabled=0 diff --git a/docker/base/sources.list.ubuntu b/docker/base/sources.list.ubuntu index d913a40448..9ec6da2e56 100644 --- a/docker/base/sources.list.ubuntu +++ b/docker/base/sources.list.ubuntu @@ -1,3 +1,5 @@ +# For non-x86 architectures we use sources.list.debian.ARCHITECTURENAME + # Default repos deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse diff --git a/docker/base/sources.list.ubuntu.aarch64 b/docker/base/sources.list.ubuntu.aarch64 new file mode 100644 index 0000000000..cd742e96d3 --- /dev/null +++ b/docker/base/sources.list.ubuntu.aarch64 @@ -0,0 +1,11 @@ +# Default repos +deb http://ports.ubuntu.com/ xenial main restricted universe multiverse +deb http://ports.ubuntu.com/ xenial-updates main restricted universe multiverse +deb http://ports.ubuntu.com/ xenial-security main restricted universe multiverse + +# Backports have a lower priority and must be explicitly installed to be used +deb http://ports.ubuntu.com/ xenial-backports main restricted universe multiverse + +# We need to add the pike repo for the updated packages they provide. The main +# ones are qemu, libvirt, and openvswitch. +deb http://ubuntu-cloud.archive.canonical.com/ubuntu xenial-updates/pike main diff --git a/docker/base/sources.list.ubuntu.ppc64le b/docker/base/sources.list.ubuntu.ppc64le new file mode 100644 index 0000000000..86745c59e8 --- /dev/null +++ b/docker/base/sources.list.ubuntu.ppc64le @@ -0,0 +1,14 @@ +# Default repos +deb http://ports.ubuntu.com/ xenial main restricted universe multiverse +deb http://ports.ubuntu.com/ xenial-updates main restricted universe multiverse +deb http://ports.ubuntu.com/ xenial-security main restricted universe multiverse + +# Backports have a lower priority and must be explicitly installed to be used +deb http://ports.ubuntu.com/ xenial-backports main restricted universe multiverse + +# We need to add the pike repo for the updated packages they provide. The main +# ones are qemu, libvirt, and openvswitch. +deb http://ubuntu-cloud.archive.canonical.com/ubuntu xenial-updates/pike main + +# Mariadb +deb http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu xenial main diff --git a/kolla/common/config.py b/kolla/common/config.py index ed0dc02cbd..413a679877 100755 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -11,6 +11,7 @@ # limitations under the License. import itertools +import os from oslo_config import cfg from oslo_config import types @@ -19,7 +20,7 @@ from kolla.version import version_info as version BASE_OS_DISTRO = ['centos', 'rhel', 'ubuntu', 'oraclelinux', 'debian'] -BASE_ARCH = ['x86_64'] +BASE_ARCH = ['x86_64', 'ppc64le', 'aarch64'] DEFAULT_BASE_TAGS = { 'centos': '7', 'rhel': '7', @@ -34,9 +35,20 @@ DISTRO_RELEASE = { 'debian': 'stretch', 'ubuntu': '16.04', } + +# This is noarch repository so we will use it on all architectures DELOREAN = \ "https://trunk.rdoproject.org/centos7/current-passed-ci/delorean.repo" -DELOREAN_DEPS = "https://trunk.rdoproject.org/centos7/delorean-deps.repo" + +# TODO(hrw): with move to Pike+1 we need to make sure that aarch64 repo +# gets updated (docker/base/aarch64-cbs.repo file) +# there is ongoing work to sort that out +DELOREAN_DEPS = { + 'x86_64': "https://trunk.rdoproject.org/centos7/delorean-deps.repo", + 'aarch64': None, + 'ppc64le': None +} + INSTALL_TYPE_CHOICES = ['binary', 'source', 'rdo', 'rhos'] TARBALLS_BASE = "http://tarballs.openstack.org" @@ -153,6 +165,8 @@ _PROFILE_OPTS = [ help='Gate images') ] +hostarch = os.uname()[4] + _CLI_OPTS = [ cfg.StrOpt('base', short='b', default='centos', choices=BASE_OS_DISTRO, @@ -161,10 +175,12 @@ _CLI_OPTS = [ cfg.StrOpt('base-tag', default='latest', help='The base distro image tag'), cfg.StrOpt('base-image', - help='The base image name. Default is the same with base'), - cfg.StrOpt('base-arch', default='x86_64', + help='The base image name. Default is the same with base. ' + 'For non-x86 architectures use full name like ' + '"aarch64/debian".'), + cfg.StrOpt('base-arch', default=hostarch, choices=BASE_ARCH, - help='The base architecture'), + help='The base architecture. Default is same as host'), cfg.BoolOpt('debug', short='d', default=False, help='Turn on debugging log level'), cfg.BoolOpt('skip-parents', default=False, @@ -237,7 +253,8 @@ _BASE_OPTS = [ cfg.StrOpt('maintainer', default='Kolla Project (https://launchpad.net/kolla)', help='The MAINTAINER field'), - cfg.ListOpt('rpm_setup_config', default=[DELOREAN, DELOREAN_DEPS], + cfg.ListOpt('rpm_setup_config', default=[DELOREAN, + DELOREAN_DEPS[hostarch]], help=('Comma separated list of .rpm or .repo file(s) ' 'or URL(s) to install before building containers')), cfg.StrOpt('apt_sources_list', help=('Path to custom sources.list')), diff --git a/kolla/image/build.py b/kolla/image/build.py index ff2409c631..85b96e2949 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -604,6 +604,7 @@ class KollaWorker(object): """Generates a list of docker commands based on provided configuration. :param rpm_setup_config: A list of .rpm or .repo paths or URLs + (can be empty) :return: A list of docker commands """ rpm_setup = list() @@ -621,6 +622,8 @@ class KollaWorker(object): else: # Copy .repo file from filesystem cmd = "COPY {} /etc/yum.repos.d/".format(config) + elif config is None: + cmd = '' else: raise exception.KollaRpmSetupUnknownConfig( 'RPM setup must be provided as .rpm or .repo files.' diff --git a/releasenotes/notes/ubuntu-sources.list-change-65bb0f936b0ec95b.yaml b/releasenotes/notes/ubuntu-sources.list-change-65bb0f936b0ec95b.yaml new file mode 100644 index 0000000000..70780e30c4 --- /dev/null +++ b/releasenotes/notes/ubuntu-sources.list-change-65bb0f936b0ec95b.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + For non-x86 architectures Ubuntu sources.list got defined in other file: + "sources.list.ubuntu.ARCHNAME" (where ARCHNAME is "aarch64" or "ppc64le"). + This way x86-64 users do not have to adapt their configurations if they + have own set of repositories for Ubuntu.