From c22cf33268979db15f06f2bab347750127e5d7ee Mon Sep 17 00:00:00 2001 From: Vladislav Belogrudov Date: Wed, 2 Sep 2015 17:36:46 +0300 Subject: [PATCH] Allow arbitrary source archive name to be imported into Dockerfile Currently we cannot import source archives with names different than expected by hardcoded line in Dockerfiles. This worked well for Openstack services' tarballs where we expected SERVICE-* root folder after extraction or kanaka-noVNC for nova-novncproxy docker. The latter fails if one tries to clone or get tarball under other names. This fix allows any archive (tar,tgz,zip) or repo name to be imported into dockerfile. Change-Id: I869a6a19afaf0e93925572746c22b7589b6600c9 Closes-Bug: #1491415 --- .../ceilometer/ceilometer-base/Dockerfile.j2 | 4 ++-- docker/cinder/cinder-base/Dockerfile.j2 | 4 ++-- docker/designate/designate-base/Dockerfile.j2 | 4 ++-- docker/glance/glance-base/Dockerfile.j2 | 4 ++-- docker/gnocchi/gnocchi-base/Dockerfile.j2 | 4 ++-- docker/heat/heat-base/Dockerfile.j2 | 4 ++-- docker/horizon/Dockerfile.j2 | 4 ++-- docker/ironic/ironic-base/Dockerfile.j2 | 4 ++-- docker/keystone/Dockerfile.j2 | 4 ++-- docker/magnum/magnum-base/Dockerfile.j2 | 4 ++-- docker/murano/murano-base/Dockerfile.j2 | 4 ++-- docker/neutron/neutron-base/Dockerfile.j2 | 4 ++-- docker/nova/nova-base/Dockerfile.j2 | 4 ++-- docker/nova/nova-novncproxy/Dockerfile.j2 | 4 ++-- docker/swift/swift-base/Dockerfile.j2 | 4 ++-- docker/zaqar/Dockerfile.j2 | 4 ++-- kolla/cmd/build.py | 18 ++++++++---------- 17 files changed, 40 insertions(+), 42 deletions(-) diff --git a/docker/ceilometer/ceilometer-base/Dockerfile.j2 b/docker/ceilometer/ceilometer-base/Dockerfile.j2 index 230a19ab42..a1f701a246 100644 --- a/docker/ceilometer/ceilometer-base/Dockerfile.j2 +++ b/docker/ceilometer/ceilometer-base/Dockerfile.j2 @@ -10,8 +10,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \ {% endif %} {% elif install_type == 'source' %} -ADD ceilometer-base.tar / -RUN ln -s /ceilometer-* ceilometer \ +ADD ceilometer-base-archive /ceilometer-base-source +RUN ln -s ceilometer-base-source/* ceilometer \ && useradd --user-group ceilometer \ && pip --no-cache-dir install /ceilometer \ && mkdir -p /etc/ceilometer /var/log/ceilometer /home/ceilometer \ diff --git a/docker/cinder/cinder-base/Dockerfile.j2 b/docker/cinder/cinder-base/Dockerfile.j2 index 855c0c667d..f2f2b215e7 100644 --- a/docker/cinder/cinder-base/Dockerfile.j2 +++ b/docker/cinder/cinder-base/Dockerfile.j2 @@ -33,8 +33,8 @@ RUN apt-get install -y --no-install-recommends lvm2 \ {% endif %} -ADD cinder-base.tar / -RUN ln -s /cinder-* cinder \ +ADD cinder-base-archive /cinder-base-source +RUN ln -s cinder-base-source/* cinder \ && useradd --user-group cinder \ && pip --no-cache-dir install /cinder \ && mkdir -p /etc/cinder /var/log/cinder /home/cinder \ diff --git a/docker/designate/designate-base/Dockerfile.j2 b/docker/designate/designate-base/Dockerfile.j2 index 8f6afa925c..bb1847e1e9 100644 --- a/docker/designate/designate-base/Dockerfile.j2 +++ b/docker/designate/designate-base/Dockerfile.j2 @@ -25,8 +25,8 @@ RUN echo '{{ install_type}} not yet available for {{ base_distro }}' \ {% endif %} {% elif install_type == 'source' %} -ADD designate-base.tar / -RUN ln -s /designate-* designate \ +ADD designate-base-archive /designate-base-source +RUN ln -s designate-base-source/* designate \ && useradd --user-group designate \ && pip --no-cache-dir install /designate \ && mkdir -p /etc/designate /var/log/designate /home/designate \ diff --git a/docker/glance/glance-base/Dockerfile.j2 b/docker/glance/glance-base/Dockerfile.j2 index 4fe27a4a88..4cb6710fb4 100644 --- a/docker/glance/glance-base/Dockerfile.j2 +++ b/docker/glance/glance-base/Dockerfile.j2 @@ -17,8 +17,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \ {% endif %} {% elif install_type == 'source' %} -ADD glance-base.tar / -RUN ln -s /glance-* glance \ +ADD glance-base-archive /glance-base-source +RUN ln -s glance-base-source/* glance \ && useradd --user-group glance \ && pip --no-cache-dir install /glance \ && mkdir -p /etc/glance /var/log/glance /home/glance \ diff --git a/docker/gnocchi/gnocchi-base/Dockerfile.j2 b/docker/gnocchi/gnocchi-base/Dockerfile.j2 index 764bd7e869..05230fb5c9 100644 --- a/docker/gnocchi/gnocchi-base/Dockerfile.j2 +++ b/docker/gnocchi/gnocchi-base/Dockerfile.j2 @@ -14,8 +14,8 @@ RUN apt-get install -y --no-install-recommends libpq-dev \ {% endif %} -ADD gnocchi-base.tar / -RUN ln -s /gnocchi-* gnocchi \ +ADD gnocchi-base-archive /gnocchi-base-source +RUN ln -s gnocchi-base-source/* gnocchi \ && useradd --user-group gnocchi \ && pip --no-cache-dir install /gnocchi \ && mkdir -p /etc/gnocchi /var/log/gnocchi /home/gnocchi \ diff --git a/docker/heat/heat-base/Dockerfile.j2 b/docker/heat/heat-base/Dockerfile.j2 index 7f210a5035..ac0002de90 100644 --- a/docker/heat/heat-base/Dockerfile.j2 +++ b/docker/heat/heat-base/Dockerfile.j2 @@ -16,8 +16,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \ {% endif %} {% elif install_type == 'source' %} -ADD heat-base.tar / -RUN ln -s /heat-* heat \ +ADD heat-base-archive /heat-base-source +RUN ln -s heat-base-source/* heat \ && useradd --user-group heat \ && pip --no-cache-dir install /heat \ && mkdir -p /etc/heat /var/log/heat /home/heat \ diff --git a/docker/horizon/Dockerfile.j2 b/docker/horizon/Dockerfile.j2 index 8bf6babdd5..6c9bb4949c 100644 --- a/docker/horizon/Dockerfile.j2 +++ b/docker/horizon/Dockerfile.j2 @@ -50,8 +50,8 @@ RUN apt-get install -y --no-install-recommends \ {% endif %} -ADD horizon.tar / -RUN ln -s /horizon-* horizon \ +ADD horizon-archive /horizon-source +RUN ln -s horizon-source/* horizon \ && pip --no-cache-dir install /horizon \ && useradd --user-group horizon \ && mkdir -p /etc/openstack-dashboard /home/horizon \ diff --git a/docker/ironic/ironic-base/Dockerfile.j2 b/docker/ironic/ironic-base/Dockerfile.j2 index 4de31d2b7d..c83cf2ee22 100644 --- a/docker/ironic/ironic-base/Dockerfile.j2 +++ b/docker/ironic/ironic-base/Dockerfile.j2 @@ -20,8 +20,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \ {% endif %} {% elif install_type == 'source' %} -ADD ironic-base.tar / -RUN ln -s /ironic-* ironic \ +ADD ironic-base-archive /ironic-base-source +RUN ln -s ironic-base-source/* ironic \ && useradd --user-group ironic \ && pip --no-cache-dir install /ironic \ && mkdir -p /etc/ironic /var/log/ironic /home/ironic \ diff --git a/docker/keystone/Dockerfile.j2 b/docker/keystone/Dockerfile.j2 index e71d7dfb9f..264d6ff093 100644 --- a/docker/keystone/Dockerfile.j2 +++ b/docker/keystone/Dockerfile.j2 @@ -49,8 +49,8 @@ RUN apt-get install -y --no-install-recommends \ {% endif %} -ADD keystone.tar / -RUN ln -s /keystone-* keystone \ +ADD keystone-archive /keystone-source +RUN ln -s keystone-source/* keystone \ && useradd --user-group keystone \ && pip --no-cache-dir install /keystone \ && mkdir -p /etc/keystone /var/www/cgi-bin/keystone /var/log/apache2 /home/keystone \ diff --git a/docker/magnum/magnum-base/Dockerfile.j2 b/docker/magnum/magnum-base/Dockerfile.j2 index d83fa86a8e..c3d6aa6afb 100644 --- a/docker/magnum/magnum-base/Dockerfile.j2 +++ b/docker/magnum/magnum-base/Dockerfile.j2 @@ -18,8 +18,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \ {% endif %} {% elif install_type == 'source' %} -ADD magnum-base.tar / -RUN ln -s /magnum-* magnum \ +ADD magnum-base-archive /magnum-base-source +RUN ln -s magnum-base-source/* magnum \ && useradd --user-group magnum \ && pip --no-cache-dir install /magnum \ && mkdir -p /etc/magnum /var/log/magnum /home/magnum \ diff --git a/docker/murano/murano-base/Dockerfile.j2 b/docker/murano/murano-base/Dockerfile.j2 index 5dc28caca6..e92f8a328a 100644 --- a/docker/murano/murano-base/Dockerfile.j2 +++ b/docker/murano/murano-base/Dockerfile.j2 @@ -8,8 +8,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \ {% elif install_type == 'source' %} -ADD murano-base.tar / -RUN ln -s /murano-* murano \ +ADD murano-base-archive /murano-base-source +RUN ln -s murano-base-source/* murano \ && useradd --user-group murano \ && pip --no-cache-dir install /murano \ && mkdir -p /etc/murano /var/log/murano /home/murano \ diff --git a/docker/neutron/neutron-base/Dockerfile.j2 b/docker/neutron/neutron-base/Dockerfile.j2 index 79d4ab4eaa..e3cb222cca 100644 --- a/docker/neutron/neutron-base/Dockerfile.j2 +++ b/docker/neutron/neutron-base/Dockerfile.j2 @@ -31,8 +31,8 @@ RUN apt-get install -y --no-install-recommends \ {% endif %} -ADD neutron-base.tar / -RUN ln -s /neutron-* neutron \ +ADD neutron-base-archive /neutron-base-source +RUN ln -s neutron-base-source/* neutron \ && useradd --user-group neutron \ && pip --no-cache-dir install /neutron \ && mkdir -p /etc/neutron /usr/share/neutron /var/log/neutron /home/neutron \ diff --git a/docker/nova/nova-base/Dockerfile.j2 b/docker/nova/nova-base/Dockerfile.j2 index ad43bb9c4e..476c7bca9f 100644 --- a/docker/nova/nova-base/Dockerfile.j2 +++ b/docker/nova/nova-base/Dockerfile.j2 @@ -39,8 +39,8 @@ RUN apt-get install -y --no-install-recommends \ {% endif %} -ADD nova-base.tar / -RUN ln -s /nova-* nova \ +ADD nova-base-archive /nova-base-source +RUN ln -s nova-base-source/* nova \ && useradd --user-group nova \ && pip --no-cache-dir install /nova \ && mkdir -p /etc/nova /var/log/nova /home/nova \ diff --git a/docker/nova/nova-novncproxy/Dockerfile.j2 b/docker/nova/nova-novncproxy/Dockerfile.j2 index a2fcf98cc8..1a90e4f01f 100644 --- a/docker/nova/nova-novncproxy/Dockerfile.j2 +++ b/docker/nova/nova-novncproxy/Dockerfile.j2 @@ -12,8 +12,8 @@ RUN yum -y install \ {% endif %} {% elif install_type == 'source' %} -ADD nova-novncproxy.tar / -RUN ln -s /kanaka-noVNC-* /usr/share/novnc +ADD nova-novncproxy-archive /nova-novncproxy-source +RUN ln -s nova-novncproxy-source/* /usr/share/novnc {% endif %} diff --git a/docker/swift/swift-base/Dockerfile.j2 b/docker/swift/swift-base/Dockerfile.j2 index 7a20e2864a..54011cedb6 100644 --- a/docker/swift/swift-base/Dockerfile.j2 +++ b/docker/swift/swift-base/Dockerfile.j2 @@ -15,8 +15,8 @@ RUN echo '{{ install_type}} not yet available for {{ base_distro }}' \ {% elif install_type == 'source' %} -ADD swift-base.tar / -RUN ln -s /swift-* swift \ +ADD swift-base-archive /swift-base-source +RUN ln -s swift-base-source/* swift \ && useradd --user-group swift \ && pip --no-cache-dir install /swift \ && mkdir -p /etc/swift /var/log/swift /home/swift \ diff --git a/docker/zaqar/Dockerfile.j2 b/docker/zaqar/Dockerfile.j2 index 4e3a0bc52c..e41e94698b 100644 --- a/docker/zaqar/Dockerfile.j2 +++ b/docker/zaqar/Dockerfile.j2 @@ -14,8 +14,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \ {% endif %} {% elif install_type == 'source' %} -ADD zaqar.tar / -RUN ln -s /zaqar-* zaqar \ +ADD zaqar-archive /zaqar-source +RUN ln -s zaqar-source/* zaqar \ && useradd --user-group zaqar \ && pip --no-cache-dir install /zaqar \ && mkdir -p /etc/zaqar /var/log/zaqar /home/zaqar \ diff --git a/kolla/cmd/build.py b/kolla/cmd/build.py index 17142b54b0..437f19cc4f 100755 --- a/kolla/cmd/build.py +++ b/kolla/cmd/build.py @@ -88,27 +88,25 @@ class WorkerThread(Thread): def process_source(self, image): source = image['source'] - dest_dir = image['path'] - dest_tar = os.path.join(dest_dir, image['name'] + '.tar') + dest_archive = os.path.join(image['path'], image['name'] + '-archive') if source.get('type') == 'url': - LOG.debug("{}:Getting tarball from {}".format(image['name'], + LOG.debug("{}:Getting archive from {}".format(image['name'], source['source'])) r = requests.get(source['source']) if r.status_code == 200: - with open(dest_tar, 'wb') as f: + with open(dest_archive, 'wb') as f: f.write(r.content) else: LOG.error( - '{}:Failed to download tarball: status_code {}'.format( + '{}:Failed to download archive: status_code {}'.format( image['name'], r.status_code)) image['status'] = "error" return elif source.get('type') == 'git': - clone_dir = os.path.splitext(dest_tar)[0] + \ - '-' + source['reference'] + clone_dir = dest_archive + '-' + source['reference'] try: LOG.debug("{}:Cloning from {}".format(image['name'], source['source'])) @@ -125,7 +123,7 @@ class WorkerThread(Thread): image['status'] = "error" return - with tarfile.open(dest_tar, 'w') as tar: + with tarfile.open(dest_archive, 'w') as tar: tar.add(clone_dir, arcname=os.path.basename(clone_dir)) else: @@ -134,8 +132,8 @@ class WorkerThread(Thread): image['status'] = "error" return - # Set time on destination tarball to epoch 0 - os.utime(dest_tar, (0, 0)) + # Set time on destination archive to epoch 0 + os.utime(dest_archive, (0, 0)) def builder(self, image): LOG.debug('{}:Processing'.format(image['name']))