From a833b762d7c86f8b83c4b64335ac45c0b687ef96 Mon Sep 17 00:00:00 2001 From: Goutham Pacha Ravi Date: Wed, 20 May 2020 17:31:12 -0700 Subject: [PATCH] Modify job to build images We currently only build the generic driver image with the job "manila-image-elements-buildimage-generic". Since we'd like to use a cephfs based client image, we can reuse the job to produce two images instead of one. The new job "manila-image-elements-buildimages" produces two images: "manila-service-image-cephfs-{tag}.qcow2" and "manila-service-image-{tag}.qcow2"; where the tag corresponds to the version of this project. The job also creates a soft link of the tagged images with a "-master" suffix instead of the tag - this is useful for CI jobs that don't need to worry about changing/using the latest tag. Change-Id: I60c6b38b5d5de7649c0d760519a79288fafca1e3 Signed-off-by: Goutham Pacha Ravi --- .zuul.yaml | 15 +++--- playbooks/manila-buildimage-generic/run.yaml | 39 -------------- playbooks/manila-buildimages/run.yaml | 3 ++ roles/build-mie-images/README.rst | 14 ++++++ roles/build-mie-images/defaults/main.yml | 4 ++ roles/build-mie-images/tasks/main.yml | 53 ++++++++++++++++++++ tools/gate/build-images | 10 +++- 7 files changed, 89 insertions(+), 49 deletions(-) delete mode 100644 playbooks/manila-buildimage-generic/run.yaml create mode 100644 playbooks/manila-buildimages/run.yaml create mode 100644 roles/build-mie-images/README.rst create mode 100644 roles/build-mie-images/defaults/main.yml create mode 100644 roles/build-mie-images/tasks/main.yml mode change 100755 => 100644 tools/gate/build-images diff --git a/.zuul.yaml b/.zuul.yaml index 88bf9a2..9e3e33f 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -6,7 +6,7 @@ check: jobs: - openstack-tox-pep8 - - manila-image-elements-buildimage-generic + - manila-image-elements-buildimages - manila-image-elements-buildimage-docker: voting: false - manila-tempest-dsvm-container-scenario-custom-image: @@ -22,7 +22,7 @@ gate: jobs: - openstack-tox-pep8 - - manila-image-elements-buildimage-generic + - manila-image-elements-buildimages post: jobs: - manila-image-elements-publish-artifacts @@ -38,14 +38,15 @@ run: playbooks/manila-buildimage-docker/run.yaml - job: - name: manila-image-elements-buildimage-generic + name: manila-image-elements-buildimages description: | - Build service image for the "generic" manila back end. + Build service image for the "generic" manila back end, and any other + images specified in the role "build-mie-images" parent: unittests timeout: 1800 required-projects: - openstack/manila-image-elements - run: playbooks/manila-buildimage-generic/run.yaml + run: playbooks/manila-buildimages/run.yaml - job: name: manila-image-elements-publish-artifacts @@ -56,7 +57,5 @@ final: true required-projects: - openstack/manila-image-elements - run: playbooks/manila-buildimage-generic/run.yaml + run: playbooks/manila-buildimages/run.yaml post-run: playbooks/manila-publish-artifacts/post.yaml - - diff --git a/playbooks/manila-buildimage-generic/run.yaml b/playbooks/manila-buildimage-generic/run.yaml deleted file mode 100644 index 882801f..0000000 --- a/playbooks/manila-buildimage-generic/run.yaml +++ /dev/null @@ -1,39 +0,0 @@ -- hosts: all - tasks: - - name: Run tools/gate/build-images generic - command: bash -xe tools/gate/build-images generic - args: - chdir: '{{ zuul.project.src_dir }}' - - name: create images directory - file: - path: '{{ zuul.project.src_dir }}/images' - state: directory - mode: 0755 - - name: Collect git tag - command: git describe --tags - args: - chdir: '{{ zuul.project.src_dir }}' - register: tagoutput - - name: show directory contents after the build - command: ls -lrt - args: - chdir: '{{ zuul.project.src_dir }}' - - name: get the source directory - command: pwd - args: - chdir: '{{ zuul.project.src_dir }}' - register: src_dir - - name: hard link to image from images directory using tag - file: - src: '{{ src_dir.stdout }}/manila-service-image.qcow2' - dest: '{{ src_dir.stdout }}/images/manila-service-image-{{ tagoutput.stdout }}.qcow2' - state: hard - - name: now symlink using "master" in place of tag - file: - src: '{{ src_dir.stdout }}/images/manila-service-image-{{ tagoutput.stdout }}.qcow2' - dest: '{{ src_dir.stdout }}/images/manila-service-image-master.qcow2' - state: link - - name: show contents of the image directory - command: ls -lrt - args: - chdir: '{{ src_dir.stdout }}/images' diff --git a/playbooks/manila-buildimages/run.yaml b/playbooks/manila-buildimages/run.yaml new file mode 100644 index 0000000..538a323 --- /dev/null +++ b/playbooks/manila-buildimages/run.yaml @@ -0,0 +1,3 @@ +- hosts: all + roles: + - build-mie-images \ No newline at end of file diff --git a/roles/build-mie-images/README.rst b/roles/build-mie-images/README.rst new file mode 100644 index 0000000..a42514d --- /dev/null +++ b/roles/build-mie-images/README.rst @@ -0,0 +1,14 @@ +build-mie-images +================ + +An ansible role to build images with manila-image-elements + +Role Variables +-------------- + +.. zuul:rolevar:: images_to_build + :type: list + :default: ['generic', 'cephfs'] + + + One or more image types to build. diff --git a/roles/build-mie-images/defaults/main.yml b/roles/build-mie-images/defaults/main.yml new file mode 100644 index 0000000..41647f2 --- /dev/null +++ b/roles/build-mie-images/defaults/main.yml @@ -0,0 +1,4 @@ +--- +images_to_build: + - cephfs + - generic \ No newline at end of file diff --git a/roles/build-mie-images/tasks/main.yml b/roles/build-mie-images/tasks/main.yml new file mode 100644 index 0000000..70c756b --- /dev/null +++ b/roles/build-mie-images/tasks/main.yml @@ -0,0 +1,53 @@ +--- +- name: build the requested images + command: bash -xe tools/gate/build-images {{ item }} + args: + chdir: "{{ zuul.project.src_dir }}" + with_items: "{{ images_to_build }}" +- name: create images directory + file: + path: "{{ zuul.project.src_dir }}/images" + state: directory + mode: 0755 +- name: collect git tag + command: git describe --tags + args: + chdir: "{{ zuul.project.src_dir }}" + register: tagoutput +- name: show directory contents after the build + command: ls -lrt + args: + chdir: "{{ zuul.project.src_dir }}" +- name: get the source directory + command: pwd + args: + chdir: '{{ zuul.project.src_dir }}' + register: src_dir +- name: grab all images built + find: + paths: "{{ src_dir.stdout }}" + patterns: '*.qcow2' + file_type: file + register: images_built +- name: hard link images into the images directory using the git tag + file: + src: "{{ item.path }}" + dest: "{{ src_dir.stdout }}/images/{{ item.path | basename | splitext | first }}-{{ tagoutput.stdout }}.qcow2" + state: hard + with_items: "{{ images_built.files }}" +- name: grab the tagged images + find: + paths: "{{ src_dir.stdout }}/images" + patterns: "*.qcow2" + file_type: file + register: images_tagged +- name: create "master" symlinks for these images + file: + src: "{{ item.path }}" + dest: "{{ src_dir.stdout }}/images/{{ item.path | basename | regex_replace('\\d+.*qcow2', 'master.qcow2') }}" + state: link + with_items: "{{ images_tagged.files }}" +- name: get contents of the images directory + command: ls -lrt + args: + chdir: "{{ zuul.project.src_dir }}/images/" diff --git a/tools/gate/build-images b/tools/gate/build-images old mode 100755 new mode 100644 index e7877de..89d98ed --- a/tools/gate/build-images +++ b/tools/gate/build-images @@ -1,7 +1,9 @@ #!/bin/bash -xe -# Argument is expected to be type of image - either 'generic' or -# 'docker'. +# Argument is expected to be type of image. Use 'generic' to build an image +# with NFS and CIFS for use with Manila's Generic driver. Or specify a +# protocol (ex: cephfs) to build an image with protocol specific packages, +# or use "docker" to build a container image for use with the Container driver. IMAGE=$1 @@ -11,6 +13,10 @@ if [[ "$IMAGE" == "generic"* ]]; then elif [[ "$IMAGE" == @(docker|container)* ]]; then tox -v -e buildimage-docker image_name="manila-docker-container.tar.gz" +else + export MANILA_IMG_NAME="manila-service-image-$IMAGE" + tox -v -e buildimage -- -s $IMAGE + image_name="$MANILA_IMG_NAME.qcow2" fi echo $image_name > ./IMAGE_NAME