Option to upload Octavia amphora img in RAW format

When deploying an overcloud with Octavia, the amphora image is uploaded
to Glance as QCOW2. When using the RBD backend for Glance and Nova, this
causes the image to be converted to RAW on each deployment. With slower
storage, this leads to load balancer creation to fail with a compute
timeout exception from Octavia.

This patch adds an option to allow amphora image to be automatically
uploaded to Glance in raw format.

Partial-Bug: #1778303
Change-Id: I698ed96881756bb547f5338b147b0c795103acb5
This commit is contained in:
Carlos Goncalves 2018-06-22 18:24:31 -04:00
parent 6902268191
commit 73631a23ee
4 changed files with 33 additions and 2 deletions

View File

@ -6,6 +6,7 @@
amp_ssh_key_name: "{{ amp_ssh_key_name }}"
amp_ssh_key_path: "{{ amp_ssh_key_path }}"
amp_ssh_key_data: "{{ amp_ssh_key_data }}"
amp_to_raw: "{{ amp_to_raw | bool }}"
auth_username: "{{ auth_username }}"
auth_pasword: "{{ auth_password }}"
auth_project_name: "{{ auth_project_name }}"

View File

@ -4,6 +4,7 @@ amp_image_filename: ""
amp_image_tag: "amphora-image"
amp_ssh_key_name: "octavia-ssh-key"
amp_ssh_key_path: ""
amp_to_raw: False
auth_username: "octavia"
auth_project_name: "service"
lb_mgmt_net_name: "lb-mgmt-net"

View File

@ -48,10 +48,37 @@
upload_image: true
when: current_md5 is not defined or replace_image
- block:
- name: create temporary directory
tempfile:
state: directory
register: amp_tmp_dir
- name: set RAW file name
set_fact:
raw_filename: "{{ amp_tmp_dir.path }}/{{ image_filename|splitext|first|basename }}.img"
- name: convert image from qcow2 to raw
shell: |
qemu-img convert -f qcow2 -O raw {{ image_filename }} {{ raw_filename }}
- name: setting amphora format to raw
set_fact:
raw_format: raw
when: amp_to_raw
- name: upload image to glance
shell: |
openstack image create --disk-format qcow2 --container-format bare --tag {{ amp_image_tag }} \
--file {{ image_filename }} {{ amphora_image }}
openstack image create --disk-format {{ raw_format|default('qcow2') }} \
--container-format bare --tag {{ amp_image_tag }} \
--file {{ raw_filename|default(image_filename) }} \
{{ amphora_image }}
register: image_result
changed_when: "image_result.stdout != ''"
when: image_file_result.stat.exists and upload_image is defined
- name: delete converted raw image
file:
path: "{{ amp_tmp_dir.path }}"
state: absent
when: amp_to_raw

View File

@ -14,6 +14,7 @@ workflows:
- amp_ssh_key_name
- amp_ssh_key_path
- amp_ssh_key_data
- amp_to_raw
- auth_username
- auth_password
- auth_project_name
@ -103,6 +104,7 @@ workflows:
amp_ssh_key_name: <% $.amp_ssh_key_name %>
amp_ssh_key_path: <% $.amp_ssh_key_path %>
amp_ssh_key_data: <% $.amp_ssh_key_data %>
amp_to_raw: <% $.amp_to_raw %>
auth_username: <% $.auth_username %>
auth_password: <% $.auth_password %>
auth_project_name: <% $.auth_project_name %>