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 <gouthampravi@gmail.com>
This commit is contained in:
Goutham Pacha Ravi 2020-05-20 17:31:12 -07:00
parent c127687d3d
commit a833b762d7
7 changed files with 89 additions and 49 deletions

View File

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

View File

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

View File

@ -0,0 +1,3 @@
- hosts: all
roles:
- build-mie-images

View File

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

View File

@ -0,0 +1,4 @@
---
images_to_build:
- cephfs
- generic

View File

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

10
tools/gate/build-images Executable file → Normal file
View File

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