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
This commit is contained in:
Marcin Juszkiewicz
2017-01-31 17:55:12 +01:00
parent 7b27262216
commit 2e43891838
8 changed files with 165 additions and 30 deletions

View File

@@ -42,6 +42,21 @@ RUN CURRENT_DISTRO_RELEASE=$(awk '{match($0, /[0-9]+/,version)}END{print version
#### BEGIN REPO ENABLEMENT #### BEGIN REPO ENABLEMENT
{% set base_yum_repo_files = [ {% set base_yum_repo_files = [
] %}
{% 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', 'elasticsearch.repo',
'grafana.repo', 'grafana.repo',
'influxdb.repo', 'influxdb.repo',
@@ -50,25 +65,29 @@ RUN CURRENT_DISTRO_RELEASE=$(awk '{match($0, /[0-9]+/,version)}END{print version
'td.repo', 'td.repo',
'zookeeper.repo' 'zookeeper.repo'
] %} ] %}
{%- 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 = [ {% set base_yum_url_packages = [
'http://repo.percona.com/release/7/RPMS/x86_64/percona-release-0.1-4.noarch.rpm' '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 = [ {% set base_yum_repo_keys = [
'http://yum.mariadb.org/RPM-GPG-KEY-MariaDB', 'http://yum.mariadb.org/RPM-GPG-KEY-MariaDB',
'/etc/pki/rpm-gpg/RPM-GPG-KEY-Percona ', '/etc/pki/rpm-gpg/RPM-GPG-KEY-Percona',
'https://packages.elastic.co/GPG-KEY-elasticsearch', 'https://packages.elastic.co/GPG-KEY-elasticsearch',
'https://repos.influxdata.com/influxdb.key', 'https://repos.influxdata.com/influxdb.key',
'https://packagecloud.io/gpg.key', 'https://packagecloud.io/gpg.key',
'https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana', 'https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana',
'https://packages.treasuredata.com/GPG-KEY-td-agent' 'https://packages.treasuredata.com/GPG-KEY-td-agent'
] %} ] %}
{% endif %}
{%- for key in base_yum_repo_keys | customizable('yum_repo_keys') %} {%- for repo_file in base_yum_repo_files | customizable('yum_repo_files') %}
COPY {{ repo_file }} /etc/yum.repos.d/{{ repo_file }}
{%- endfor %}
{{ macros.install_packages(base_yum_url_packages | customizable("yum_url_packages")) }}
{% for key in base_yum_repo_keys | customizable('yum_repo_keys') %}
{%- if loop.first %}RUN {% else %} && {% endif -%} {%- if loop.first %}RUN {% else %} && {% endif -%}
rpm --import {{ key }} rpm --import {{ key }}
{%- if not loop.last %} \{% endif %} {%- if not loop.last %} \{% endif %}
@@ -100,17 +119,25 @@ RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
{% endblock %} {% endblock %}
{% set base_centos_yum_repo_keys = [ {% 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 = [ {% set base_centos_yum_repo_packages = [
'centos-release-ceph-jewel',
'centos-release-qemu-ev',
'epel-release', 'epel-release',
'yum-plugin-priorities' '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")) }} {{ 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') %} {% for key in base_centos_yum_repo_keys | customizable('centos_yum_repo_keys') %}
{%- if loop.first %}RUN {% else %} && {% endif -%} {%- 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: {# We are back to the basic if conditional here which is:
if base_distro in ['centos', 'oraclelinux', 'rhel'] #} if base_distro in ['centos', 'oraclelinux', 'rhel'] #}
{% set base_compiler_packages = [
'gcc',
'glibc-static'
] %}
{% block base_redhat_binary_versionlock %}{% endblock %} {% block base_redhat_binary_versionlock %}{% endblock %}
{% if install_type == 'binary' %} {% if install_type == 'binary' %}
{% set base_centos_binary_packages = [ {% set base_centos_binary_packages = [
@@ -228,7 +261,11 @@ RUN apt-get update \
{% endblock %} {% endblock %}
{% block base_ubuntu_package_sources_list %} {% 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 COPY sources.list.{{ base_distro }} /etc/apt/sources.list
{% else %}
COPY sources.list.{{ base_distro }}.{{ base_arch }} /etc/apt/sources.list
{% endif %}
{% endblock %} {% endblock %}
{% block base_ubuntu_package_apt_preferences %} {% block base_ubuntu_package_apt_preferences %}
@@ -248,6 +285,9 @@ COPY apt_preferences.{{ base_distro }} /etc/apt/preferences
'sudo', 'sudo',
'tgt'] 'tgt']
%} %}
{% set base_compiler_packages = [
'build-essential'
] %}
{% if base_distro == 'ubuntu' %} {% if base_distro == 'ubuntu' %}
{# 05CE15085FC09D18E99EFB22684A14CF2582E0C5 -- InfluxDB Packaging Service <support@influxdb.com> #} {# 05CE15085FC09D18E99EFB22684A14CF2582E0C5 -- InfluxDB Packaging Service <support@influxdb.com> #}
@@ -322,8 +362,23 @@ COPY sudoers /etc/sudoers
COPY curlrc /root/.curlrc COPY curlrc /root/.curlrc
{% block dumb_init_installation %} {% 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 \ 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 && 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 %} {% endblock %}
RUN touch /usr/local/bin/kolla_extend_start \ RUN touch /usr/local/bin/kolla_extend_start \

View File

@@ -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

View File

@@ -1,3 +1,5 @@
# For non-x86 architectures we use sources.list.debian.ARCHITECTURENAME
# Default repos # Default repos
deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse

View File

@@ -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

View File

@@ -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

View File

@@ -11,6 +11,7 @@
# limitations under the License. # limitations under the License.
import itertools import itertools
import os
from oslo_config import cfg from oslo_config import cfg
from oslo_config import types 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_OS_DISTRO = ['centos', 'rhel', 'ubuntu', 'oraclelinux', 'debian']
BASE_ARCH = ['x86_64'] BASE_ARCH = ['x86_64', 'ppc64le', 'aarch64']
DEFAULT_BASE_TAGS = { DEFAULT_BASE_TAGS = {
'centos': '7', 'centos': '7',
'rhel': '7', 'rhel': '7',
@@ -34,9 +35,20 @@ DISTRO_RELEASE = {
'debian': 'stretch', 'debian': 'stretch',
'ubuntu': '16.04', 'ubuntu': '16.04',
} }
# This is noarch repository so we will use it on all architectures
DELOREAN = \ DELOREAN = \
"https://trunk.rdoproject.org/centos7/current-passed-ci/delorean.repo" "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'] INSTALL_TYPE_CHOICES = ['binary', 'source', 'rdo', 'rhos']
TARBALLS_BASE = "http://tarballs.openstack.org" TARBALLS_BASE = "http://tarballs.openstack.org"
@@ -153,6 +165,8 @@ _PROFILE_OPTS = [
help='Gate images') help='Gate images')
] ]
hostarch = os.uname()[4]
_CLI_OPTS = [ _CLI_OPTS = [
cfg.StrOpt('base', short='b', default='centos', cfg.StrOpt('base', short='b', default='centos',
choices=BASE_OS_DISTRO, choices=BASE_OS_DISTRO,
@@ -161,10 +175,12 @@ _CLI_OPTS = [
cfg.StrOpt('base-tag', default='latest', cfg.StrOpt('base-tag', default='latest',
help='The base distro image tag'), help='The base distro image tag'),
cfg.StrOpt('base-image', cfg.StrOpt('base-image',
help='The base image name. Default is the same with base'), help='The base image name. Default is the same with base. '
cfg.StrOpt('base-arch', default='x86_64', 'For non-x86 architectures use full name like '
'"aarch64/debian".'),
cfg.StrOpt('base-arch', default=hostarch,
choices=BASE_ARCH, choices=BASE_ARCH,
help='The base architecture'), help='The base architecture. Default is same as host'),
cfg.BoolOpt('debug', short='d', default=False, cfg.BoolOpt('debug', short='d', default=False,
help='Turn on debugging log level'), help='Turn on debugging log level'),
cfg.BoolOpt('skip-parents', default=False, cfg.BoolOpt('skip-parents', default=False,
@@ -237,7 +253,8 @@ _BASE_OPTS = [
cfg.StrOpt('maintainer', cfg.StrOpt('maintainer',
default='Kolla Project (https://launchpad.net/kolla)', default='Kolla Project (https://launchpad.net/kolla)',
help='The MAINTAINER field'), 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) ' help=('Comma separated list of .rpm or .repo file(s) '
'or URL(s) to install before building containers')), 'or URL(s) to install before building containers')),
cfg.StrOpt('apt_sources_list', help=('Path to custom sources.list')), cfg.StrOpt('apt_sources_list', help=('Path to custom sources.list')),

View File

@@ -604,6 +604,7 @@ class KollaWorker(object):
"""Generates a list of docker commands based on provided configuration. """Generates a list of docker commands based on provided configuration.
:param rpm_setup_config: A list of .rpm or .repo paths or URLs :param rpm_setup_config: A list of .rpm or .repo paths or URLs
(can be empty)
:return: A list of docker commands :return: A list of docker commands
""" """
rpm_setup = list() rpm_setup = list()
@@ -621,6 +622,8 @@ class KollaWorker(object):
else: else:
# Copy .repo file from filesystem # Copy .repo file from filesystem
cmd = "COPY {} /etc/yum.repos.d/".format(config) cmd = "COPY {} /etc/yum.repos.d/".format(config)
elif config is None:
cmd = ''
else: else:
raise exception.KollaRpmSetupUnknownConfig( raise exception.KollaRpmSetupUnknownConfig(
'RPM setup must be provided as .rpm or .repo files.' 'RPM setup must be provided as .rpm or .repo files.'

View File

@@ -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.