From bd5e5bbb64b20eb4c77c2a941973845d847e9d78 Mon Sep 17 00:00:00 2001 From: Steven Dake Date: Thu, 13 Aug 2015 14:26:55 -0700 Subject: [PATCH] Use one data container for all data volumes The previous method of using the API image for a data container worked, but resulted in more data being bindmounted and copied into the system. This patch resolves that by essentially using a distro-type as a FROM in a Dockerfile to generate distro-type-data. Further all of the data containers used throughout ansible are modified to use this new data container. Change-Id: I8846573d4f2d4b98d4f46c770bfefc6d4c5cd0b5 Partially-Implements: blueprint one-data-container --- ansible/roles/cinder/defaults/main.yml | 6 +++++- ansible/roles/cinder/tasks/bootstrap.yml | 3 +-- ansible/roles/glance/defaults/main.yml | 4 ++++ ansible/roles/glance/tasks/bootstrap.yml | 3 +-- ansible/roles/mariadb/defaults/main.yml | 4 ++++ ansible/roles/mariadb/tasks/bootstrap.yml | 3 +-- ansible/roles/rabbitmq/defaults/main.yml | 4 ++++ ansible/roles/rabbitmq/tasks/bootstrap.yml | 3 +-- docker/centos/binary/data/Dockerfile | 4 ++++ docker/centos/binary/data/build | 1 + docker/centos/binary/galera/Dockerfile | 3 ++- docker/centos/binary/rabbitmq/Dockerfile | 3 ++- docker/centos/source/data/Dockerfile | 4 ++++ docker/centos/source/data/build | 1 + docker/common/galera/config-galera.sh | 9 ++------- docker/common/rabbitmq/config-rabbit.sh | 2 +- docker_templates/data/Dockerfile.j2 | 4 ++++ docker_templates/galera/Dockerfile.j2 | 6 +++++- docker_templates/rabbitmq/Dockerfile.j2 | 6 ++++-- tools/init-runonce | 2 +- 20 files changed, 52 insertions(+), 23 deletions(-) create mode 100644 docker/centos/binary/data/Dockerfile create mode 120000 docker/centos/binary/data/build create mode 100644 docker/centos/source/data/Dockerfile create mode 120000 docker/centos/source/data/build create mode 100644 docker_templates/data/Dockerfile.j2 diff --git a/ansible/roles/cinder/defaults/main.yml b/ansible/roles/cinder/defaults/main.yml index 6af5f7df89..3bb0081a2c 100644 --- a/ansible/roles/cinder/defaults/main.yml +++ b/ansible/roles/cinder/defaults/main.yml @@ -28,6 +28,10 @@ cinder_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ dock cinder_api_tag: "{{ openstack_release }}" cinder_api_image_full: "{{ cinder_api_image }}:{{ cinder_api_tag }}" +cinder_data_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-data" +cinder_data_image_tag: "{{ openstack_release }}" +cinder_data_image_full: "{{ cinder_data_image }}:{{ cinder_data_image_tag }}" + #################### # Openstack @@ -41,4 +45,4 @@ cinder_logging_debug: "{{ openstack_logging_debug }}" cinder_keystone_user: "cinder" -openstack_cinder_auth: "{'auth_url':'{{ openstack_auth_v2.auth_url }}','username':'{{ openstack_auth_v2.username }}','password':'{{ openstack_auth_v2.password }}','project_name':'{{ openstack_auth_v2.project_name }}'}" \ No newline at end of file +openstack_cinder_auth: "{'auth_url':'{{ openstack_auth_v2.auth_url }}','username':'{{ openstack_auth_v2.username }}','password':'{{ openstack_auth_v2.password }}','project_name':'{{ openstack_auth_v2.project_name }}'}" diff --git a/ansible/roles/cinder/tasks/bootstrap.yml b/ansible/roles/cinder/tasks/bootstrap.yml index e157ce5ec5..9482b56493 100644 --- a/ansible/roles/cinder/tasks/bootstrap.yml +++ b/ansible/roles/cinder/tasks/bootstrap.yml @@ -40,8 +40,7 @@ password: "{{ docker_registry_password }}" insecure_registry: "{{ docker_insecure_registry }}" name: cinder_data - image: "{{ cinder_api_image_full }}" - command: "/bin/sleep infinity" + image: "{{ cinder_data_image_full }}" volumes: "/var/lib/cinder/" - name: Starting Cinder bootstrap container diff --git a/ansible/roles/glance/defaults/main.yml b/ansible/roles/glance/defaults/main.yml index 15062b8dff..0ebe84b2cd 100644 --- a/ansible/roles/glance/defaults/main.yml +++ b/ansible/roles/glance/defaults/main.yml @@ -20,6 +20,10 @@ glance_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ dock glance_api_tag: "{{ openstack_release }}" glance_api_image_full: "{{ glance_api_image }}:{{ glance_api_tag }}" +glance_data_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-data" +glance_data_image_tag: "{{ openstack_release }}" +glance_data_image_full: "{{ glance_data_image }}:{{ glance_data_image_tag }}" + #################### # Openstack diff --git a/ansible/roles/glance/tasks/bootstrap.yml b/ansible/roles/glance/tasks/bootstrap.yml index f8d3c6534d..49d57f7630 100644 --- a/ansible/roles/glance/tasks/bootstrap.yml +++ b/ansible/roles/glance/tasks/bootstrap.yml @@ -40,8 +40,7 @@ password: "{{ docker_registry_password }}" insecure_registry: "{{ docker_insecure_registry }}" name: glance_data - image: "{{ glance_registry_image_full }}" - command: "/bin/sleep infinity" + image: "{{ glance_data_image_full }}" volumes: "/var/lib/glance/" - name: Starting Glance bootstrap container diff --git a/ansible/roles/mariadb/defaults/main.yml b/ansible/roles/mariadb/defaults/main.yml index 2be21a4bce..e2e6dd432f 100644 --- a/ansible/roles/mariadb/defaults/main.yml +++ b/ansible/roles/mariadb/defaults/main.yml @@ -13,3 +13,7 @@ database_cluster_name: "openstack" mariadb_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-galera" mariadb_tag: "{{ openstack_release }}" mariadb_image_full: "{{ mariadb_image }}:{{ mariadb_tag }}" + +mariadb_data_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-data" +mariadb_data_tag: "{{ openstack_release }}" +mariadb_data_image_full: "{{ mariadb_data_image }}:{{ mariadb_data_tag }}" diff --git a/ansible/roles/mariadb/tasks/bootstrap.yml b/ansible/roles/mariadb/tasks/bootstrap.yml index f31153c026..e616cf7a57 100644 --- a/ansible/roles/mariadb/tasks/bootstrap.yml +++ b/ansible/roles/mariadb/tasks/bootstrap.yml @@ -49,8 +49,7 @@ password: "{{ docker_registry_password }}" insecure_registry: "{{ docker_insecure_registry }}" name: mariadb_data - image: "{{ mariadb_image_full }}" - command: "/bin/sleep infinity" + image: "{{ mariadb_data_image_full }}" volumes: "/var/lib/mysql/" - name: Starting MariaDB bootstrap container diff --git a/ansible/roles/rabbitmq/defaults/main.yml b/ansible/roles/rabbitmq/defaults/main.yml index b3ae1e9ca0..6cf3246bcf 100644 --- a/ansible/roles/rabbitmq/defaults/main.yml +++ b/ansible/roles/rabbitmq/defaults/main.yml @@ -8,6 +8,10 @@ rabbitmq_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker rabbitmq_tag: "{{ openstack_release }}" rabbitmq_image_full: "{{ rabbitmq_image }}:{{ rabbitmq_tag }}" +rabbitmq_data_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-data" +rabbitmq_data_tag: "{{ openstack_release }}" +rabbitmq_data_image_full: "{{ rabbitmq_data_image }}:{{ rabbitmq_data_tag }}" + #################### # Message-Broker diff --git a/ansible/roles/rabbitmq/tasks/bootstrap.yml b/ansible/roles/rabbitmq/tasks/bootstrap.yml index 97cba11643..233e2ee383 100644 --- a/ansible/roles/rabbitmq/tasks/bootstrap.yml +++ b/ansible/roles/rabbitmq/tasks/bootstrap.yml @@ -20,8 +20,7 @@ password: "{{ docker_registry_password }}" insecure_registry: "{{ docker_insecure_registry }}" name: rabbitmq_data - image: "{{ rabbitmq_image_full }}" - command: "/bin/sleep infinity" + image: "{{ rabbitmq_data_image_full }}" volumes: "/var/lib/rabbitmq/" - name: Starting RabbitMQ bootstrap container diff --git a/docker/centos/binary/data/Dockerfile b/docker/centos/binary/data/Dockerfile new file mode 100644 index 0000000000..6359185407 --- /dev/null +++ b/docker/centos/binary/data/Dockerfile @@ -0,0 +1,4 @@ +FROM centos +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +CMD /bin/sleep infinity diff --git a/docker/centos/binary/data/build b/docker/centos/binary/data/build new file mode 120000 index 0000000000..8d652f7ee2 --- /dev/null +++ b/docker/centos/binary/data/build @@ -0,0 +1 @@ +../../../../tools/build-docker-image \ No newline at end of file diff --git a/docker/centos/binary/galera/Dockerfile b/docker/centos/binary/galera/Dockerfile index e4171165be..9a21c3440f 100644 --- a/docker/centos/binary/galera/Dockerfile +++ b/docker/centos/binary/galera/Dockerfile @@ -19,7 +19,8 @@ RUN echo "[mariadb]" > /etc/yum.repos.d/MariaDB.repo && \ percona-xtrabackup \ pv \ tar \ - expect + expect \ + && rm -rf /var/lib/mysql/* COPY config-galera.sh /opt/kolla/config/ COPY config-external.sh /opt/kolla/ diff --git a/docker/centos/binary/rabbitmq/Dockerfile b/docker/centos/binary/rabbitmq/Dockerfile index 51197ca431..88894c3c70 100644 --- a/docker/centos/binary/rabbitmq/Dockerfile +++ b/docker/centos/binary/rabbitmq/Dockerfile @@ -5,7 +5,8 @@ RUN yum -y install \ hostname \ rabbitmq-server && \ yum clean all && \ - /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management + /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management \ + && rm -rf /var/lib/rabbitmq/* COPY config-rabbit.sh config-external.sh /opt/kolla/ COPY start.sh / diff --git a/docker/centos/source/data/Dockerfile b/docker/centos/source/data/Dockerfile new file mode 100644 index 0000000000..6359185407 --- /dev/null +++ b/docker/centos/source/data/Dockerfile @@ -0,0 +1,4 @@ +FROM centos +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +CMD /bin/sleep infinity diff --git a/docker/centos/source/data/build b/docker/centos/source/data/build new file mode 120000 index 0000000000..8d652f7ee2 --- /dev/null +++ b/docker/centos/source/data/build @@ -0,0 +1 @@ +../../../../tools/build-docker-image \ No newline at end of file diff --git a/docker/common/galera/config-galera.sh b/docker/common/galera/config-galera.sh index 8aab3cfe11..42393377db 100755 --- a/docker/common/galera/config-galera.sh +++ b/docker/common/galera/config-galera.sh @@ -74,13 +74,8 @@ function configure_db { } function populate_db { - if [[ $(ls /var/lib/mysql) == "" ]]; then - echo "POPULATING NEW DB" - mysql_install_db - chown -R mysql: /var/lib/mysql - else - echo "DB ALREADY EXISTS" - fi + mysql_install_db + chown -R mysql: /var/lib/mysql } function prepare_db { diff --git a/docker/common/rabbitmq/config-rabbit.sh b/docker/common/rabbitmq/config-rabbit.sh index 6f2283c67f..c87a2ab48b 100644 --- a/docker/common/rabbitmq/config-rabbit.sh +++ b/docker/common/rabbitmq/config-rabbit.sh @@ -2,6 +2,6 @@ function set_rabbitmq_cookie { echo "${RABBITMQ_CLUSTER_COOKIE}" > /var/lib/rabbitmq/.erlang.cookie - chown rabbitmq: /var/lib/rabbitmq/.erlang.cookie + chown -R rabbitmq: /var/lib/rabbitmq chmod 400 /var/lib/rabbitmq/.erlang.cookie } diff --git a/docker_templates/data/Dockerfile.j2 b/docker_templates/data/Dockerfile.j2 new file mode 100644 index 0000000000..18933ef559 --- /dev/null +++ b/docker_templates/data/Dockerfile.j2 @@ -0,0 +1,4 @@ +FROM {{ base_distro }}:{{ base_distro_tag }} +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +CMD /bin/sleep infinity diff --git a/docker_templates/galera/Dockerfile.j2 b/docker_templates/galera/Dockerfile.j2 index 90975ddabe..2d656053ae 100644 --- a/docker_templates/galera/Dockerfile.j2 +++ b/docker_templates/galera/Dockerfile.j2 @@ -21,12 +21,16 @@ RUN yum install -y http://www.percona.com/redir/downloads/percona-release/redhat percona-xtrabackup \ pv \ tar \ - expect + expect \ + && rm -rf /var/lib/mysql/* {% elif base_distro in ['ubuntu', 'debian'] %} RUN ["/bin/false"] +# TODO(sdake) when ubuntu support is implemented we will need a line +# && rm -rf /var/lib/mysql/ + {% endif %} COPY config-galera.sh /opt/kolla/config/ diff --git a/docker_templates/rabbitmq/Dockerfile.j2 b/docker_templates/rabbitmq/Dockerfile.j2 index 63dc1ff3c2..119a303173 100644 --- a/docker_templates/rabbitmq/Dockerfile.j2 +++ b/docker_templates/rabbitmq/Dockerfile.j2 @@ -6,14 +6,16 @@ MAINTAINER Kolla Project (https://launchpad.net/kolla) RUN yum -y install \ hostname \ rabbitmq-server \ - && yum clean all + && yum clean all \ + && rm -rf /var/lib/rabbitmq/* {% elif base_distro in ['ubuntu', 'debian'] %} RUN apt-get install -y --no-install-recommends \ hostname \ rabbitmq-server \ - && apt-get clean + && apt-get clean \ + && rm -rf /var/lib/rabbitmq/* {% endif %} diff --git a/tools/init-runonce b/tools/init-runonce index e7727b82ea..c0ffc5c4cb 100755 --- a/tools/init-runonce +++ b/tools/init-runonce @@ -37,7 +37,7 @@ if ! [ -f "$IMAGE" ]; then curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE fi echo Creating glance image. -glance image-create --name cirros --progress --disk-format qcow2 --container-format bare --visibility public --progress --file ./$IMAGE +glance image-create --name cirros --progress --disk-format qcow2 --container-format bare --progress --file ./$IMAGE if [[ "${NETWORK_MANAGER}" == "nova" ]] ; then echo Configuring nova networking.