From 11f9afba1b0b9e8f30770aacfe75ae3c07ffc486 Mon Sep 17 00:00:00 2001 From: Jeffrey Zhang Date: Wed, 15 Nov 2017 10:12:54 +0800 Subject: [PATCH] Pull image from dockerhub rather than tarballs.o.o site Change-Id: Id71c1ecda9f8647a0eb290fe02a12afb3df09988 --- tests/post.yml | 5 +++++ tests/run.yml | 27 +++++++++++++++++++++++ tests/templates/docker_daemon.json.j2 | 6 ++++++ tests/templates/globals-default.j2 | 6 ++++++ tools/setup_gate.sh | 31 ++++++--------------------- 5 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 tests/templates/docker_daemon.json.j2 diff --git a/tests/post.yml b/tests/post.yml index 97a9cfaaa2..a92cdcb3df 100644 --- a/tests/post.yml +++ b/tests/post.yml @@ -3,6 +3,11 @@ vars: logs_dir: "/tmp/logs" tasks: + - name: Print all facts + copy: + content: "{{ hostvars[inventory_hostname] | to_nice_json }}" + dest: "{{ logs_dir }}/facts.json" + - name: Run diagnostics script script: get_logs.sh register: get_logs_result diff --git a/tests/run.yml b/tests/run.yml index f1adf6982c..abf5c56185 100644 --- a/tests/run.yml +++ b/tests/run.yml @@ -5,6 +5,7 @@ logs_dir: "/tmp/logs" kolla_ansible_src_dir: "src/{{ zuul.project.canonical_hostname }}/openstack/kolla-ansible" kolla_ansible_full_src_dir: "{{ zuul.executor.work_root }}/{{ kolla_ansible_src_dir }}" + need_build_image: false tasks: - name: ensure /etc/kolla exists file: @@ -46,6 +47,13 @@ with_items: "{{ ansible_interfaces }}" delegate_to: "primary" + - name: detect whether need build images + set_fact: + need_build_image: true + when: + - item.project.short_name == "kolla" + with_items: "{{ zuul['items'] }}" + - name: generate global.yml file template: src: "{{ kolla_ansible_full_src_dir }}/tests/templates/globals-default.j2" @@ -72,6 +80,22 @@ dest: /etc/kolla/passwords.yml delegate_to: "primary" + - name: ensure /etc/docker exists + file: + path: "/etc/docker" + state: "directory" + mode: 0777 + become: true + + - name: create deamon.json for nodepool cache + vars: + infra_dockerhub_mirror: "http://{{ zuul_site_mirror_fqdn }}:8081/registry-1.docker/" + template: + src: "{{ kolla_ansible_full_src_dir }}/tests/templates/docker_daemon.json.j2" + dest: "/etc/docker/daemon.json" + become: true + + - name: install kolla-ansible requirements pip: requirements: "{{ ansible_env.HOME }}/{{ kolla_ansible_src_dir }}/requirements.txt" @@ -89,6 +113,9 @@ export INSTALL_TYPE={{ install_type }} export NODEPOOL_TARBALLS_MIRROR=http://{{ zuul_site_mirror_fqdn }}:8080/tarballs + export BUILD_IMAGE={{ need_build_image }} + export KOLLA_SRC_DIR={{ ansible_env.HOME }}/src/git.openstack.org/openstack/kolla + tools/setup_gate.sh executable: /bin/bash chdir: "{{ kolla_ansible_src_dir }}" diff --git a/tests/templates/docker_daemon.json.j2 b/tests/templates/docker_daemon.json.j2 new file mode 100644 index 0000000000..b35d7589bb --- /dev/null +++ b/tests/templates/docker_daemon.json.j2 @@ -0,0 +1,6 @@ +{ + "debug": true, + "registry-mirrors": [ + "{{ infra_dockerhub_mirror }}" + ] +} diff --git a/tests/templates/globals-default.j2 b/tests/templates/globals-default.j2 index 4404f9875c..8020aefcff 100644 --- a/tests/templates/globals-default.j2 +++ b/tests/templates/globals-default.j2 @@ -11,9 +11,15 @@ kolla_internal_vip_address: "169.254.169.10" network_interface: "{{ api_interface_name }}" docker_restart_policy: "never" +{% if need_build_image %} # NOTE(Jeffrey4l): use different a docker namespace name in case it pull image from hub.docker.io when deplying docker_namespace: "lokolla" docker_registry: "{{ api_interface_address }}:4000" +{% else %} +# use docker hub images +docker_namespace: "kolla" +openstack_release: "queens" +{% endif %} neutron_external_interface: "fake_interface" enable_horizon: "yes" enable_heat: "no" diff --git a/tools/setup_gate.sh b/tools/setup_gate.sh index 2af7ede5c7..989163c854 100755 --- a/tools/setup_gate.sh +++ b/tools/setup_gate.sh @@ -34,11 +34,6 @@ EOF echo "RUN echo $(base64 -w0 ${PIP_CONF}) | base64 -d > /etc/pip.conf" | sudo tee /etc/kolla/header rm ${PIP_CONF} - # Get base distro and install type from workspace. The full path looks like - # /home/jenkins/workspace/gate-kolla-ansible-dsvm-deploy-centos-source-centos-7-nv - - # NOTE(Jeffrey4l): use different a docker namespace name in case it pull image from hub.docker.io when deplying - GATE_IMAGES="cron,fluentd,glance,haproxy,keepalived,keystone,kolla-toolbox,mariadb,memcached,neutron,nova,openvswitch,rabbitmq,horizon" # TODO(jeffrey4l): this doesn't work with zuulv3 @@ -69,7 +64,7 @@ EOF apt_sources_list = /etc/kolla/sources.list EOF sudo cp /etc/apt/sources.list /etc/kolla/sources.list - sudo cat /etc/apt/sources.list.available.d/ubuntu-cloud-archive.list | sudo tee -a /etc/kolla/sources.list + sudo cat /etc/apt/sources.list.available.d/ubuntu-cloud-archive-pike.list | sudo tee -a /etc/kolla/sources.list # Append non-infra provided repos to list cat << EOF | sudo tee -a /etc/kolla/sources.list deb http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu xenial main @@ -108,25 +103,13 @@ function setup_node { } function prepare_images { - sudo docker run -d -p 4000:5000 --restart=always -v /opt/kolla_registry/:/var/lib/registry --name registry registry:2 - - # NOTE(Jeffrey4l): Zuul adds all changes depend on to ZUUL_CHANGES - # variable. if find "openstack/kolla:" string, it means this patch depends - # on one of Kolla patch. Then build image by using Kolla's code. - # Otherwise, pull images from tarballs.openstack.org site. - # NOTE(inc0): Publisher variable is set when Kolla runs publisher jobs. - # When that happens we don't build images, we download them from temp location. - if echo "$ZUUL_CHANGES" | grep -i "openstack/kolla:" && ! [[ $PUBLISHER ]]; then - pushd "${GIT_PROJECT_DIR}/kolla" - sudo tox -e "build-${BASE_DISTRO}-${INSTALL_TYPE}" - popd - else - BRANCH=$(echo "$ZUUL_BRANCH" | cut -d/ -f2) - filename=${BASE_DISTRO}-${INSTALL_TYPE}-registry-${BRANCH}.tar.gz - wget -q -c -O "/tmp/$filename" \ - "${NODEPOOL_TARBALLS_MIRROR}/kolla/images/${TMP_REGISTRY}${filename}" - sudo tar xzf "/tmp/$filename" -C /opt/kolla_registry + if [[ "${BUILD_IMAGE}" == "False" ]]; then + return fi + sudo docker run -d -p 4000:5000 --restart=always -v /opt/kolla_registry/:/var/lib/registry --name registry registry:2 + pushd "${KOLLA_SRC_DIR}" + sudo tox -e "build-${BASE_DISTRO}-${INSTALL_TYPE}" + popd } function sanity_check {